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,199 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

slubman
- 2,277
- 16
- 12
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

Ali Mezgani
- 3,850
- 2
- 24
- 36