繁体   English   中英

如何根据字符代码或ASCII代码值对文本文件进行排序?

[英]How to sort a text file according to character code or ASCII code value?

我想按命令行根据字符代码或ASCII代码值对文本行进行排序。 我尝试了以下命令行,但结果不是我的预期。

# string="   8888888
>'
> Transportation
> Temp
>temp
>TEMP
>    99
>    Temp
>  Temporary"
# LC_ALL=C echo "$string" | sort 
'
   8888888
    99
temp
 Temp
    Temp
TEMP
  Temporary
 Transportation

要根据ASCII代码值进行排序,输出应该如下

    99
    Temp
   8888888
  Temporary
 Temp
 Transportation
'
TEMP
temp

有谁知道这是怎么做到的吗?

你已经搞错了错误的程序。

echo "$string" | LC_ALL=C sort

使用$LC_COLLATE也是可以接受的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM