如何使用计划 9 的 sed 从行首删除空格



似乎这应该从每行的开头最多删除 2 个空格:cat test.txt | 9 sed 's/^ //g; 相反,它替换了行首的所有空格。GNU 的 sed 似乎正如我在这里所期望的那样,为了进行比较,但我有兴趣学习 Plan 9 的方式。

注意:这里的9 sed语法是因为我从plan9port运行它。

更详细地说:

$ cat test.txt
This
is
a test.
Bye
$ cat test.txt | 9 sed 's/^  //g'
This
is
a test.
Bye

我希望输出更像是使用 GNUsed

$ cat test.txt | sed 's/^  //g'
This
is
a test.
Bye

看起来计划 9s sed 在治疗时被破坏了

sed 's/^  //g'

好像是(伪代码(:

do
sed 's/^  //'
until the sed output is no longer different from the input

或:

sed 's/^  *//'

或类似的,而不是正确的解释,

这与不存在g相同:
sed 's/^  //'

最新更新