Using SED in a script

Jack L. Stone webster at sageweb.net
Tue Feb 17 17:03:44 PST 2004


Sorry if this is somewhat OT, but I *think* I have a simple SED(1)
question for those familiar with its use.

I am working up a small script that will grep(1) a string like "215 new
messages" from a file for use as a variable. I need to then find/replace
an "old string" in another file that may say "198 new messages" with the
new variable string "215 new messages". So, only the numeric part of the
string actually changes.

I've looked at the sed approach, but not sure how to apply its use here,
or if something else besides sed(1) would be better.

This would be the steps:
- grep(1) the new string and pipe to sed(1) ..??
- sed(1) to find the old string & replace with the new string in a file.

Am I on the right track....??

Tips on the script syntax appreciated.

Thanks and....

Happy Trails,

Jack L. Stone
SageWeb


More information about the freebsd-questions mailing list