我有一个文件a.txt。 我想用该文件中的“1.5”replace“1.6”的所有实例,覆盖原始文件。
使用命令行:
sed -i .bak -e 's/1\.5/1.6/g' /path/to/file
该命令在文件中replace,原始文件保存为/path/to/file.bak
你可以使用sed:
sed 's/1\.5/1\.6/g' /path/to/file | tee output
另外如果你是像vim这样的编辑器的话,你可以这样做:
vim /path/to/file :%s/1\.5/1\.6/g
在emacs中:
emacs /path/to/file Mx replace-string