我正在尝试编写一个 sed 命令来替换文件中过多的空格。每个单词之间应该只有一个空格,但前导空格和制表符应该单独留下。所以文件:
This is an indented paragraph. The indentation should not be changed.
This is the second line of the paragraph.
Run Code Online (Sandbox Code Playgroud)
会变成:
This is an indented paragraph. The indentation should not be changed.
This is the second line of the paragraph.
Run Code Online (Sandbox Code Playgroud)
我尝试过
/^[ \t]*/!s/[ \t]+/ /g
Run Code Online (Sandbox Code Playgroud)
任何想法,将不胜感激。
sed ×1