I have a file a.txt. I would like to replace all instances of "1.6" with "1.5" in that file, overwriting the original file.
Asked
Active
Viewed 1,094 times
2 Answers
11
Using the command line :
sed -i .bak -e 's/1\.5/1.6/g' /path/to/file
This command replace in the file, the orginal file is saved as /path/to/file.bak
![](../../users/profiles/17993.webp)
slubman
- 2,247
- 16
- 11
7
You can use sed for that:
sed 's/1\.5/1\.6/g' /path/to/file | tee output
also if you are inside an editor like vim, you can do that :
vim /path/to/file
:%s/1\.5/1\.6/g
In emacs :
emacs /path/to/file
M-x replace-string
![](../../users/profiles/15197.webp)
Ali Mezgani
- 3,810
- 2
- 23
- 36