我想对文件中的行上的单词逐行进行排序,并且我希望输出是按字母顺序排序的单词的行。
例如:
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/