Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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