我有问题。我有这种格式的文件:
Hi / Tom /
Be / Nice /
...
我需要删除“/”和“”(空格)并对其进行排序
Be Nice
Hi Tom
...
答案 0 :(得分:1)
for sorted_word in $(for word in $(sed -e 's/\/ //g' path_to_file); do printf "%s\n" ${word}; done | sort); do printf "%s " ${sorted_word}; done ; printf "%s\n"
答案 1 :(得分:1)
您可以使用tr
命令,如
cat inputfile.txt | tr -s "\/" "" | tr " " "\n" | sort | tr "\n" " "