find -name '*.log' -type f -print0 | xargs --null perl -pi -e 's/redhat/SUSE/'The you can tweak the first part of the command (find) to point it to the files which have to be changed. redhat will be replaced with SUSE for all log files in this case.
A blog about tips and tricks for linux - as I do some development, sometimes I find some good staff which I would like to store somewhere. I will be happy if you find this stuff to be useful for any reason.
Saturday, June 27, 2015
How to replace substring in linux
There is an easy way to do a mass replace of substring in linux. You can use perl command and a combination of "find/xargs/perl" like this:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment