Quote:
Originally Posted by asteroid4u
Hi Turbocapitalist,
I won't get old value to search and replace.
I have key word exit in file say cape=xyz and I want to replace xyz with new value that produced by script.
|
Then you'll still need the
s command in
sed and when you have the following
Code:
sed -e "s/old/new/"
you can use a pattern for "old". See
man 7 regex for the hairy details.
Don't try to use the -i option until you have a working pattern.
So you might try something like this:
Code:
#!/bin/sh
a=Grear
b=$1
sed -e "s/^${b}=.*$/${b}=${a}/" /root/file
But there are several other ways to do it as well.