How to implement the script of batch updating soft connection by linux
Editor to share with you linux how to achieve batch update soft connection script, I hope you will learn something after reading this article, let's discuss it together!
In the scenario, the soft connection with a path needs to update the target, but there are two problems with the soft connection: one is that the number is relatively large, and the other is that the path format is to operate under directory B under directory An and directory C under directory A, so write scripts to operate in batches:
#! / bin/bash
Source / etc/profile
# DATA_PATH= "/ data/share/6666/www"
DATA_PATH= "/ data/pool1/888888"
Cd $DATA_PATH
DIR_NAME= "a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9"
For DIR1 in ${DIR_NAME}; do
# echo ${DATA_PATH} / $DIR1
Test-d ${DATA_PATH} / $DIR1
If [$?-eq 0]; then
Cd ${DATA_PATH} / $DIR1
Echo "first level Loop Directory:", pwd
For DIR2 in ${DATA_PATH} / ${DIR1} / ${DIR_NAME}; do
Test-d ${DATA_PATH} / $DIR1/$ {DIR2}
If [$?-eq 0]; then
Cd ${DATA_PATH} / $DIR1/$ {DIR2}
Echo "second level Loop Directory:", pwd
For NAME in/ bin/ls-l ${DATA_PATH} / ${DIR1} / ${DIR2}; do
If [- L ${DATA_PATH} / ${DIR1} / ${DIR2} / ${NAME}]; then
Domain name obtained by echo "second level directory->, $NAME"
For LINK_NAME in ${DATA_PATH} / ${DIR1} / ${DIR2} / ${NAME}; do
If [- L ${LINK_NAME}]; then
Cd ${DATA_PATH} / ${DIR1} / ${DIR2}
Echo "Domain name Source Link path:, $LINK_NAME"
Echo "current absolute path, pwd"
S_NAME1=ls-l ${LINK_NAME} | awk'{print $9}'
Echo "Source Link Domain name:, ${S_NAME1}"
# # #
D_NAME=ls-l ${LINK_NAME} | awk-F "/ data/share/www/"'{print $2}'
Echo "destination link path:,. /.. / ${D_NAME}"
# # #
Rm-rf ${S_NAME1}
Ln-sv. /.. / ${D_NAME} ${S_NAME1}
Echo-e "current domain name processing completed, ready to wrap,\ n"
Fi
Shift
Done
Shift
Fi
Shift
Done
Fi
Shift
Done
Fi
Shift
Done
After reading this article, I believe you have a certain understanding of "linux how to achieve batch update soft connection script". If you want to know more about it, you are welcome to follow the industry information channel, thank you for reading!