Unix and Linux Tips and Stuff

Your Ad Here

Sunday, July 24, 2011

FIND and REPLACE TEXT inside a file without using TEXT Editor


FIND and REPLACE TEXT inside a file without using TEXT Editor


You can perform a text replace within a file without using VI or other text editor available on your Unix or Linux box. Below command will help you perform that action. 


Using SED:
sed -i 's/FIND TEXT/REPLACE TEXT/g' FILENAME.TXT


Using PERL:
perl -p -i -e "s/FIND TEXT/REPLACE TEXT/g" FILENAME.TXT




Where:
FIND TEXT - Content you want to replace
REPLACE TEXT - New Value of the content
FILENAME.TXT - Filename

0 Comments:

Post a Comment

<< Home