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.

link|improve this question
feedback

2 Answers

up vote 10 down vote accepted

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

link|improve this answer
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.