gpt4 book ai didi

macos - 对文件中的行中的单词进行排序并再次输出已排序的行

转载 作者:行者123 更新时间:2023-12-04 06:47:16 24 4
gpt4 key购买 nike

我想逐行对文件中的行进行排序,并且我希望输出是按字母顺序排序的行。

例如:

queue list word letter gum  
another line of example words
...

我希望输出是:
gum letter list queue word  
another example line of words
...

我似乎无法通过命令行让它工作

我可能忽略了一些事情

最佳答案

如果你安装了 perl:

perl -ne 'print join " ", sort split /\s/ ; print "\n"'

前任:
cat input | perl -ne 'print join " ", sort split /\s/ ; print "\n"' > output

关于macos - 对文件中的行中的单词进行排序并再次输出已排序的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3568914/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com