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

Thursday, July 07, 2011

FOLDING IN LINUX

Fold Long Line files to Finite Width output device 
files.

Ex: fold -b < long_line_file >folded_file

Now the folded_file will  contain output with newlines 
inserted after maximum bytes specified.  This will be 
useful when editing special files. You can do the reverse 
using "expand" command.