light-blue
asked on
basic sed - search and replace
How do I write a sed command, run through crontab (I'm doing crontab -e as root) and search for
http://www.company.com/somewhere
and replace with
<!-- BEGIN IDS -->{ID}<!-- END IDS -->http://www.company.com/somewhere
Thanks!
http://www.company.com/somewhere
and replace with
<!-- BEGIN IDS -->{ID}<!-- END IDS -->http://www.company.com/somewhere
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sed -i.bak -e 's#http://www.company.com/somewhere#<!-- BEGIN IDS -->{ID}<!-- END IDS -->&#' file
ASKER
Hmmm...it seems that none of those worked. I even tried changing the original file to have just aaabbb and running
sed 's#\(aaabbb\)#<!- BEGIN IDS -->{ID}<!- END IDS -->\1#' filename.htm
but no replacing happened.
Maybe it would more helpful (?) to say I want to replace the entire a html element tag so
http://www.somewhere.com/somplace/script.php
becomes
<!-- BEGIN IDS -->{ID}<!-- END IDS -->http://www.company.com/someplace/somescript.php
sed 's#\(aaabbb\)#<!- BEGIN IDS -->{ID}<!- END IDS -->\1#' filename.htm
but no replacing happened.
Maybe it would more helpful (?) to say I want to replace the entire a html element tag so
http://www.somewhere.com/somplace/script.php
becomes
<!-- BEGIN IDS -->{ID}<!-- END IDS -->http://www.company.com/someplace/somescript.php
ASKER
or, more likely, I'm doing something (basic) wrong. maybe if I tried a simpler example of sed, I could figure out what I'm doing incorrectly...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both! They worked perfectly, but I wasn't redirecting STDOUT properly. Duh!
Thanks again!
Thanks again!