Replace text in multiple files UBUNTU using sed

Dear All,

There was a situation that we have generated 80K text files  on multiple Ubuntu servers in which by mistake a wrong url has been printed in one of line in the file and to regenerate those 80K files suppose to take more than 4 hours per server .

As those files were generated on Ubuntu servers given a thought to try for using sed command .

by default ‘/’ is option is used in sed command but in our case the replace string was containing ‘/’ as it is a url so i was getting error

sed: -e expression #1, char xx:

so used below solution and command got successfully executed  in 3 mins each server 🙂

sed -i ‘s,abcd.com,xyz.com/lmn,g’ *.txt

-i for replace in place  and last parameter is input file name

Thanks

Prashant Deshpande

 

 

 

 

Advertisements

Leave a comment

Filed under Uncategorized

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