【发布时间】:2015-01-28 07:13:01
【问题描述】:
我有一个这样的文件:
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,但.* 匹配所有内容并删除在那里找到的所有文本。
如何将每行的最后一个空格替换为“@”?
【问题讨论】:
-
哈哈,解决这个小问题的方法很多。你看,正则表达式给了我们太多的选择:)