当前位置:网站首页>Shell script file traversal STR to array string splicing

Shell script file traversal STR to array string splicing

2022-07-05 11:30:00 Zhuge iron and steel cloud

#!/bin/bash
#file=$(cat /Users/jian.wang13/code/test/0701.txt)
#houzhui=$(awk -F '/' '{print $3}' /Users/jian.wang13/code/test/0701.txt)
houzhui=$(awk -F '/' '{print $3}' /root/snap/0701.txt)
#echo $houzhui, String splicing
qianzhui="XXXXX.com/"
for i in $houzhui
do
#     echo $i
    for j in $qianzhui
    do
        aws_jingxiang=$j$i
        cn_jingxiang="XXXXX/"$i
        echo $cn_jingxiang","$aws_jingxiang >> "/root/snap/jingxiang.txt"
        if [ $? -eq 0 ];then
            break
        fi
    done
done
#file2='/Users/jian.wang13/code/test/jingxiang.txt'
# Take out one column of each line of the file
#file3=$(cat /Users/jian.wang13/code/test/jingxiang.txt)
for line in `cat /root/snap/jingxiang.txt`
do
#    echo $line
    units=(`echo $line | tr ',' ' '`)
#    echo ${units[0]} ${units[1]}
    docker pull ${units[0]} && docker tag ${units[0]} ${units[1]} && docker push ${units[1]}

done
echo '' > "/root/snap/jingxiang.txt"

@@@@@@@@@@@@@@@@@@@@@

The background to perform &>/dev/null &

原网站

版权声明
本文为[Zhuge iron and steel cloud]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051100324190.html