【发布时间】:2018-07-20 12:26:52
【问题描述】:
例如,我们有:
This is the song that doesn`t end
什么 sed 命令会把它变成这个?
end doesn`t that song the is This
我只发现了如何反转文件中的行(又名tac):
sed -n '1!G;h;$p'
【问题讨论】:
-
您为什么认为 sed 是一个合理的选择? sed 用于
s/old/new/,仅此而已。 -
你可以调整 this sed script 来交换单词而不是字符,但这几乎肯定会是一个脆弱的、难以理解的混乱。