我有一个像这样的文件:
Once upon a time there lived a cat.
The cat lived in the forest.
The forest had many trees.
我需要用“ @”替换每行的最后一个空格,例如:
Once upon a time there lived a@cat.
The cat lived in the@forest.
The forest had many@trees.
我试过了sed 's/ .*$/@/g' file.txt
,但.*
所有内容都匹配了,并删除了那里找到的所有文本。
如何用“ @”替换每行的最后一个空格?
试试这个:
sed 's/\(.*\) /\1@/'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句