在shell裏for i in “文件”,好像只能有一個循環,好像無法設置兩個變量,同時循環。所以用個土鱉的方法實現了。。
#!/bin/sh old=/home/work/old new=/home/work/new l=$(cat ./old| wc -l) for ((i=1 ; i<=$l ; i++)) do o=$(sed -n "$i"p $old) n=$(sed -n "$i"p $new) echo "update xxxx set uid='$n' where uid='$o';" done