how to use a variable in sed command
how to use a variable in sed command
if a word and a file name are taken from user..now the word entered is to be replaced in the file specified by the user with another word..how to do that?
for e.g
if word entered is stored in $wrd and
filename is in $file
i tried to replace the word stored in $wrd by "hello" using the command:
sed 's/$wrd/hello/g' 0<$file
but it doesn't make changes
please suggest the answer...
for e.g
if word entered is stored in $wrd and
filename is in $file
i tried to replace the word stored in $wrd by "hello" using the command:
sed 's/$wrd/hello/g' 0<$file
but it doesn't make changes
please suggest the answer...
rujuta- Posts : 2
Points : 4
Join date : 2010-03-09
Re: how to use a variable in sed command
use double quotes to enclose search pattern.
- Code:
$ sed "s/$word/ORANGE/g" 1.txt
Christopher- Admin
- Posts : 240
Points : 429
Join date : 2010-02-26
Age : 30
Re: how to use a variable in sed command
hey thank you for the solution... 

rujuta- Posts : 2
Points : 4
Join date : 2010-03-09

» Please help.. cant figure out variable!
» Selenium server command options while starting server.
» unknown command "if"?!
» Command for mouse over in webdriver
» com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure.
» Selenium server command options while starting server.
» unknown command "if"?!
» Command for mouse over in webdriver
» com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure.
Permissions in this forum:
You cannot reply to topics in this forum
|
|