linux shell 按行合并拼接两个文件

    export P5FileName=${T_LOG}/PDB5fileNameTarget.txt
    export CurP5FileName=${T_LOG}/PDB5fileNameTarget_T2.txt
    export renameScript=${T_LOG}/PDB5rename.sql

generateSQLscript()
{
File1=$1
File2=$2

while
    IFS=” ” read -r x rest <&3
    IFS=” ” read -r y  rest <&4
do
    echo “alter database rename file ‘$x’ to ‘$y’; “
done 3<${File1} 4< ${File2}
}

generateSQLscript ${CurP5FileName} ${P5FileName}  > ${renameScript}

echo “The rename script for PDB5 is :”
cat ${renameScript}

 

eg.

echo "1 1 1" > tmp1
echo "2 2 2" >> tmp1
echo "3 3 3" >> tmp1

echo "a,b,c" > tmp2
echo "a,b,c" >> tmp2
echo "a,b,c" >> tmp2
while
    IFS=" " read -r x rest <&3
    IFS="," read -r y z rest <&4
do
    echo "$x:$y:$z"
done 3<tmp1 4<tmp2
1:a:b
2:a:b
3:a:b

 

 

    原文作者:mygodhome
    原文地址: https://blog.csdn.net/mygodhome/article/details/104976334
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞