sed command to replace string in all sub folders text files

This will replace all occurrences of "text1" into "text2" of all text files within all multiple sub level folders in current folder.

$ find ./ -type f | xargs sed -i ‘s/text1/text2/g’

f meant for text files

-i option for replace the strings in the txt files and overwrite it.

‘s/text1/text2/g’ in this option,
s -> string,

text1 -> old string
text2 -> new string
g -> global, this is essential if we need to replace all the occurrences in the same input file.

Advertisements

About arulalant

Currently working as "Project Scientist – C" in National Centre for Medium Range Weather Forecasting (NCMRWF), MoES, Noida, India
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to sed command to replace string in all sub folders text files

  1. good It will be useful to all.

    Like

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