Recursive string change

You want recursive change one string to another, it’s simple, you need a list with full file name path called ‘output_list’, and run command bellow:

cat output_list|while read line;
do
cp -p $line $line.bkp;
cat $line |sed ‘s/SOURCE_STRING/TARGET_STRING/g’ > $line.bkp && mv $line.bkp $line;
done

Keep in mind it’s a DANGEROUS command, double check your file list, and if necessary,  make a full backup from you system.

It will run on UNIX(ES) and Linux.

Maiquel.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s