0
#!/bin/bash
##filename:3bian1.sh
##每三行变一行
##write by 2016-01-21
a=`wc -l <11.txt`
for i in `seq $a`;do
b=$[$i%3]
if [ $b -ne 0 ];then
if [ "$i" != "$a" ];then
sed -n "$i"p 11.txt|tr "\n" " "
else
sed -n "$i"p 11.txt
fi
else
sed -n "$i"p 11.txt
fi
done
##filename:3bian1.sh
##每三行变一行
##write by 2016-01-21
a=`wc -l <11.txt`
for i in `seq $a`;do
b=$[$i%3]
if [ $b -ne 0 ];then
if [ "$i" != "$a" ];then
sed -n "$i"p 11.txt|tr "\n" " "
else
sed -n "$i"p 11.txt
fi
else
sed -n "$i"p 11.txt
fi
done
0
#!/bin/bash
#write by 2016-1-31
>2.txt
>3.txt
n=$(cat /tmp/1.txt|sed -n ''p|wc -l)
for i in $(seq 1 $n)
do
if [ $(($i%3)) != 0 ]
then
sed -n "$i"p /tmp/1.txt >> /tmp/2.txt
else
sed -n "$i"p /tmp/1.txt >> /tmp/2.txt
cat /tmp/2.txt |xargs >> /tmp/3.txt
> /tmp/2.txt
fi
done
if [ $(($n%3)) -gt 0 ]
then
cat /tmp/2.txt |xargs >> /tmp/3.txt
> /tmp/2.txt
fi
cat /tmp/3.txt > /tmp/1.txt
cat 1.txt
1 2 3
4 5 6
7
#write by 2016-1-31
>2.txt
>3.txt
n=$(cat /tmp/1.txt|sed -n ''p|wc -l)
for i in $(seq 1 $n)
do
if [ $(($i%3)) != 0 ]
then
sed -n "$i"p /tmp/1.txt >> /tmp/2.txt
else
sed -n "$i"p /tmp/1.txt >> /tmp/2.txt
cat /tmp/2.txt |xargs >> /tmp/3.txt
> /tmp/2.txt
fi
done
if [ $(($n%3)) -gt 0 ]
then
cat /tmp/2.txt |xargs >> /tmp/3.txt
> /tmp/2.txt
fi
cat /tmp/3.txt > /tmp/1.txt
cat 1.txt
1 2 3
4 5 6
7
编辑回复