1755716 Members
3011 Online
108837 Solutions
New Discussion юеВ

Sed Command help . . .

 
SOLVED
Go to solution
piyush mathiya
Trusted Contributor

Sed Command help . . .

Hi Gurus,
I am very new with sed & awk command,
I want to replace "/usr/local/bin/scandir" with "/tmp/abc". how can i replace it. i have used the following steps but then also it is not working.
Please suggest me.

x=/usr/local/bin/scandir
y=/tmp/abc
sed 's/'$x'/'$y'/' scan.sh > scan.sh.tmp

Thanks,
Piyush Mathiya
2 REPLIES 2
Steven Schweda
Honored Contributor
Solution

Re: Sed Command help . . .

dyi # x='/usr/local/bin/scandir'
dyi # y='/tmp/abc'
dyi # echo 'ABC/usr/local/bin/scandir/DEF' |
sed -e "s|$x|$y|"
ABC/tmp/abc/DEF

You don't _need_ to use "/" in the sed "s"
command, and it's hard to make it work when
your strings contain "/".
piyush mathiya
Trusted Contributor

Re: Sed Command help . . .

Yes Men it is working . . .
Thanks