2017-03-29 34 views

回答

4

这应该工作,因为echoxargs

xargs -n 3 file 
6

这里默认的命令是另一种

paste -d' ' - - - < file 

awk

awk 'ORS=NR%3?FS:RS' file 

pr -3ats' ' file 
2

sed随着:

sed 'N; N; s/\n/ /g' file 
3

使用rs - 重塑的数据阵列

$ cat file | rs -C' ' 2 3 
1 2 3 
4 5 6 
  • rs读取标准输入
  • -C输出列分隔
  • 2 3行和列

使用-t移调输入:

$ cat file | rs -C' ' -t 2 3 
1 3 5 
2 4 6 
+2

'rs'似乎是一个很好的工具命令。 – karakfa