Quantcast
Channel: Networking HowTos
Viewing all articles
Browse latest Browse all 62

Using sed to replace a string in a file

$
0
0
The ‘sed’ command can be used to easily replace all occurrences of one string in a text file, with another string. For example: sed -i "s/wordtofind/replacewithword/g" /path/to/file.txt This command will find all occurrences of “wordtofind” and replace them on the fly with “replacewithword” in the file “/path/to/file.txt”. The “-i” command switch specifies to edit the file in place, otherwise it will just display the output to the standard output. Run it without the “-i” switch to ensure it runs correctly,…

Read more
[...]

Viewing all articles
Browse latest Browse all 62

Trending Articles