Replace Command

Replace Command

Here is a simple way to replace text in a file, or groups of files.

Add some text to a file:

aaron@myexample:~/test$ echo “Hello World”  > somefile.txt

View the contents of the file:

aaron@myexample:~/test$ cat somefile.txt

Hello World

Replace World => Dave

aaron@myexample:~/test$ replace World Dave < somefile.txt > someotherfile.txt

View the new file:

aaron@myexample:~/test$ cat someotherfile.txt
Hello Dave

You have to have mysql-server installed to get the command line tool.

Leave a Reply

Your email address will not be published.