sed question

How can I use sed to

1) delete a create part of a string? Go to position 3 and delete everything after or pattern match to a poistion and delete after that.

2) insert a string into another string?

thanks.

Don't use an external command to manipulate strings. The shell can do it with parameter expansion.

See the stringfuncs library in my book, Shell Scripting Recipes: A Problem-Solution Approach. The scripts are available at
http://shell.cfajohnson.com/ssr/ssr-scripts.tar.gz

I can't get to the site because of who I work for. More information:

I have these lines in a script:

base_config_a=10.2.03.390
base_config_b=9dk.305md0.00

and so on. I want to use sed to capture everything up to the = , i.e.

base_config_a=
base_config_b=

So my sed one-liner removes everything after the =.

thanks.

---------- Post updated at 03:47 PM ---------- Previous update was at 02:58 PM ----------

Ok. I got the first one be

nawk -F'[=]'  '{print $1 "="}' 

this resulted in

base_config_a=

and so on ...

Try this sed one liner

sed 's/\(^.*=\)\(.*$\)/\1/'