相关疑难解决方法(0)

按行长度(包括空格)对文本文件进行排序

我有一个看起来像这样的CSV文件

AS2345,ASDF1232, Mr. Plain Example, 110 Binary ave.,Atlantis,RI,12345,(999)123-5555,1.56
AS2345,ASDF1232, Mrs. Plain Example, 1121110 Ternary st.                                        110 Binary ave..,Atlantis,RI,12345,(999)123-5555,1.56
AS2345,ASDF1232, Mr. Plain Example, 110 Binary ave.,Liberty City,RI,12345,(999)123-5555,1.56
AS2345,ASDF1232, Mr. Plain Example, 110 Ternary ave.,Some City,RI,12345,(999)123-5555,1.56

我需要按行长度排序,包括空格.以下命令不包含空格,有没有办法修改它以便它对我有用?

cat $@ | awk '{ print length, $0 }' | sort -n | awk '{$1=""; print $0}'
Run Code Online (Sandbox Code Playgroud)

sorting bash awk text

124
推荐指数
7
解决办法
7万
查看次数

如何将文件中的行从最短到最长排序?

从最长到最短的排序行类似,如何将文件中的所有行从最短到最长排序?例如"

This is a long sentence.
This is not so long.
This is not long.

那就变成:

This is not long.
This is not so long.
This is a long sentence.

sorting bash awk

2
推荐指数
2
解决办法
2154
查看次数

标签 统计

awk ×2

bash ×2

sorting ×2

text ×1