heu*_*cus 4 linux bash shell awk sed
我在单个列中有正或负浮点值的数据,由两个空行分隔.
1.0
-2.0
3.0
4.0
-5.0
6.0
-7.0
8.0
Run Code Online (Sandbox Code Playgroud)
在bash中,将这些数据放入多个列的最佳方法是什么,以便最终结果如下所示:
1.0 3.0 -5.0 -7.0
-2.0 4.0 6.0 8.0
Run Code Online (Sandbox Code Playgroud)
在理想情况下,解决方案不仅适用于数字,还适用于以类似方式分隔的文本.
Chr*_*our 11
怎么样:
$ grep -v '^\s*$' file | pr -ts" " --columns 4
1.0 3.0 -5.0 -7.0
-2.0 4.0 6.0 8.0
Run Code Online (Sandbox Code Playgroud)
grep用于删除空行和pr格式化输出.