1

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.

Steve McLeod
  • 190
  • 1
  • 1
  • 10

2 Answers2

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,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
Ali Mezgani
  • 3,810
  • 2
  • 23
  • 36