i*****9 发帖数: 293 | 1 i have a simple file content like this:
tom
john
dennis
karl
derek
anne
....
how to print it use awk. 4 columns only, rows doesn't matter
[1] tom [2] john [3] dennis [4] karl
[5] derek [6] anne
the file might grow ... |
x**m 发帖数: 941 | 2 这样中不中?
$ awk '{ printf "[" NR "]" $1 " "; if(NR%4==0) print "\n" } input.txt |
x**m 发帖数: 941 | 3 我那浆糊般脑袋的最爱,最后一节有点问题。谁给修修?
$ sed "=" input.txt | sed "s/^[0-9]*$/[&]/g" | sed ':a;N;$!ba;s/]\n/] /g' |
tr -s '\n' ' ' | sed "s/\(\[[0-9]*\] [a-z]*\s\)\{4\}/\n/g" |
D******n 发帖数: 2836 | 4 cat _your_file_ |awk '{ORS=" ";print "["NR"] "$0 ;if (NR%4==0) print "\n"}'|
sed -e 's/^\s//g'
【在 i*****9 的大作中提到】 : i have a simple file content like this: : tom : john : dennis : karl : derek : anne : .... : how to print it use awk. 4 columns only, rows doesn't matter : [1] tom [2] john [3] dennis [4] karl
|
i*****9 发帖数: 293 | 5 nice!
'|
【在 D******n 的大作中提到】 : cat _your_file_ |awk '{ORS=" ";print "["NR"] "$0 ;if (NR%4==0) print "\n"}'| : sed -e 's/^\s//g'
|