Simple perl command for replacing text inside files

For one file
perl -p -i -e "s/<orig>/<new>/g" <filename.txt>
Or multiple files
perl -p -i -e "s/<orig>/<new>/g" *.<filetype>


About these ads
This entry was posted in fmri, unix. Bookmark the permalink.

One Response to Simple perl command for replacing text inside files

  1. M says:

    Love it! Used it a couple of times today too :) .

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 )

Connecting to %s