Saturday, January 15, 2011

one liners find and replace

You can use a perl 1 liner to do that.

$ perl -i.bak -npe 's#(<url><![CDATA[).*?(]])#$1MYURL$2#' YOURFILE

What it does:

-i.bak makes a backup copy ending in .bak in case it doesn't turn out the
way you want
-n means run the script for each line in the file
-p means print each line
-e means the script follows.

No comments: