Replace a string in a file in CLI (Command Line), Linux

For instance, you would like to replace ‘abc’ with ‘def’ everywhere in your file, do the following:

cat file1.txt | sed -e ‘s/abc/def/’ > file2.txt

Design a site like this with WordPress.com
Get started