我怎样才能重新排序升序(列)的文件? [英] How can i reorder a file by ascending order (column)?
本文介绍了我怎样才能重新排序升序(列)的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按升序时间顺序重新排列整个文件。
file.txt的是这样的:
一文12.241.45文本b 5.12文本
我想它是这样的:
1.45文本b 5.12文本一个文本12.24
解决方案
的排序
命令可能会满足您的需求好于 AWK
。
#排序-gk 2的test.txt
1.45文本
b 5.12文本
一个文本12.24
-g 他们比喻为数字而不是字符串。和 -k 2 排序在第二个栏位。
I would like to reorder a whole file by ascending time order.
file.txt looks like this:
a 12.24 text
a 1.45 text
b 5.12 text
I would like it to look like this:
a 1.45 text
b 5.12 text
a 12.24 text
解决方案
The sort
command may fit your needs better than awk
.
# sort -gk 2 test.txt
a 1.45 text
b 5.12 text
a 12.24 text
-g compares them as numbers instead of strings. And -k 2 sorts on the second column.
这篇关于我怎样才能重新排序升序(列)的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文