例99
需求:
请把下面的字符串:
zhangsan
y97JbzPru
lisi
5JhvCls6q
xiaowang
Nnr8qt2Ma
laoma
iqMtvC02y
zhaosi
9fxrb4sJD
改为如下:
zhangsan:y97JbzPru
lisi:5JhvCls6q
xiaowang:Nnr8qt2Ma
laoma:iqMtvC02y
zhaosi:9fxrb4sJD
#!/bin/bash
#这个脚本用来格式化文本
#作者:xzm
#日期:2019-12-23
n=`wc -l test3.txt|awk '{print $1}'`
n2=$[$n/2]
for i in `seq 1 $n2`
do
i2=$[$i*2]
j=$[$i2-1]
l1=`sed -n "$i2"p test3.txt`
l2=`sed -n "$j"p test3.txt`
echo $l2:$l1
done