Tag Archives: replace

A tiny script to replace all occurrences of a string in a file with another string

sed -i ‘s/original/new/g’ filename.txt This basically replaces every occurrence of the “original” string with the “new” string in the file named “filename.txt” e.g. sed -i ‘s/192.168.0.1/192.168.1.1/g’ /etc/fstab Will replace all occurrences of the IP “192.168.0.1” with the IP “192.168.1.1” in … Continue reading

Posted in Linux | Tagged , , , | 1 Comment

Replacing a string with another in a text file using sed

sed -i ‘s/old-test/new-text/g’ filename This replaces the word old-test with the word new-text in the file named filename.

Posted in Uncategorized | Tagged , , , | Leave a comment