awk or sed help
Hi All,
How can I replace the particular word using sed or awk Code:
$ BUGZILLAURL="https://mylocalserver.com/bugzilla" Code:
$ grep -i "urlbase" data/params Code:
$ grep -i "'urlbase'" data/params Thanks. |
Set the variables you need then run:
Code:
sed -i -e "/^'urlbase'/s@''@'$BUGZILLAURL/$PROJECTNAME'@g" data/params |
You should read learn and build up self capability to use sed.
Read info pages of sed. That is the official documentation about sed. It has also examples. Run: Code:
info sed |
Quote:
I ran the above command after setting the variables but it did not append the entry(https://mylocalserver.com/bugzilla/mybugs) to urlbase variable line in the data/params file. Code:
# echo "$BUGZILLAURL/$PROJECTNAME" |
^ implies the string being searched for ('urlbase') is at the start of the line, is this the case?
Also, you have been given an example, try and work with it as opposed to just trying the given solution verbatim and then saying it doesn't work. |
^ implies the string being searched for ('urlbase') is at the start of the line, is this the case?
Also, you have been given an example, try and work with it as opposed to just trying the given solution verbatim and then saying it doesn't work. |
Try this instead:
Code:
sed -i -e "/'urlbase'/s@''@'$BUGZILLAURL/$PROJECTNAME'@g" data/params Code:
sed -i -e "/^[[:space:]]\+'urlbase'/s@''@'$BUGZILLAURL/$PROJECTNAME'@g" data/params Code:
sed -i -e "/'urlbase'/s@''@'$BUGZILLAURL/$PROJECTNAME'@g" data/params |
Quote:
|
All times are GMT -5. The time now is 06:25 PM. |