- 论坛徽章:
- 0
|
#/usr/bin/sh
tmppath=`pwd`
tmptxt1=$tmppath/tmp_txt1.txt
tmptxt2=$tmppath/tmp_txt2.txt
tmptxt3=$tmppath/tmp_txt3.txt
cat $tmppath/test2.txt | while read temp
do
i=0
i=`echo $i +1 |bc`
sed -n '1,4p' test2.txt >> tmp_txt1.txt
sed -e '1,4d' test2.txt > tmp_txt2.txt
cat tmp_txt2.txt > test2.txt
sed -n '1,4p' test3.txt >> tmp_txt1.txt
sed -e '1,4d' test3.txt > tmp_txt3.txt
cat tmp_txt3.txt > test3.txt
echo "已经处理第 $i 条\n"
echo "###############"
done
cat tmp_txt1.txt > test4.txt
rm tm_txt*.txt
这里 i 的值 为什么一直是 1, 我想在执行文件的时候看下处理到第几条了
麻烦告知下..
另外上面的脚本 我是为了 txt2 的文件中每四行插入txt3中的四行....当然 2个文件的行数是一样的....
是否有其他更好的方法
如
cat txt2
11
12
13
14
15
16
17
18
cat txt3
21
22
23
24
25
26
27
28
最后的结果是
cat test4.txt
11
12
13
14
21
22
23
24
15
16
17
18
25
26
27
28
.
.
.
[ 本帖最后由 soloeyes 于 2009-7-13 14:49 编辑 ] |
|