Search My Blog

Monday, May 16, 2011

replace text in file linux

sed 's/old_text/new_text/' filename > outputfile

old_text - text to be replaced in file 'filename'
new_text - text to be substituted file 'filename'

the above command can be used to remove text from a file, by leaving the new_text blank :
sed 's/old_text//' filename > outputfile

No comments:

Post a Comment