当前位置:网站首页>shell脚本文件遍历 str转数组 字符串拼接

shell脚本文件遍历 str转数组 字符串拼接

2022-07-05 11:00:00 诸葛钢铁云

#!/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,字符串拼接
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'
# 取出文件每行的拿一列
#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"

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

后台执行 &>/dev/null &

原网站

版权声明
本文为[诸葛钢铁云]所创,转载请带上原文链接,感谢
https://blog.csdn.net/jj1130050965/article/details/125567866