Unix Programming - Re: how to use "sed" to replace old directory to new directory in a file

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2006 > Re: how to use "sed" to replace old directory to new directory in a file





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: how to use "sed" to replace old directory to new directory in a file
sk

2006-06-30, 1:20 am

i didnt get if i replace / by #

i tried lot... finally i got the answer.... we can solve in this way
also


first i tried with this....
sed
's/\/user\/xxxx\/yyyy\/zzzz\/aaaa\/bbbb\/\.cccc/\/wwww\/qqqqq\/pppp\/rrrrr\/ssss\/tttt\/\.lllll/g'

it gave error becoz it didnt accept full oldpath to newpath...

so what i did is

sed 's/user\/xxxx\/yyyy\/zzzz/ffffff/g' filename >> temporaryfile
sed 's/ffff\/aaaaa\/bbbbb\/.cccc/yyyyy/g' temporary >> temp
sed 's/yyyyy/wwww\/qqqqq\/ppppp\/rrrrr\/sssss\/tttt\/.lllllll/g' temp
mv tmpfile filename
rm temporary temp tmpfile

if i do like this am getting.... first i was so confused ..... then now
i tried like above .... i got

thanx a lot for ur response....


sk

David Bolt wrote:[vbcol=seagreen]
> On Thu, 29 Jun 2006, sk <sangeetha.kolandasamy@gmail.com> wrote:-
>
>
> Try replacing the
>
> sed "s/$oldpath/$newpath/"
>
> with
>
> sed "s#$oldpath#$newpath#"
>
> Your error is probably because the s/$oldpath/$newpath/ is expanding to
> s//user/xxxx/yyyy/zzzz/aaaa/bbbb/.cccc//wwww/qqqqq/pppp/rrrrr/ssss/tttt/.
> lllll/
>
> changing the three /'s to some other character, # in my example, means
> the / can appear as part of the search/replace string without having to
> be escaped.
>
>
> Regards,
> David Bolt
>
> --
> Member of Team Acorn checking nodes at 50 Mnodes/s: http://www.distributed.net/
> AMD1800 1Gb WinXP/SUSE 9.3 | AMD2400 256Mb SuSE 9.0 | A3010 4Mb RISCOS 3.11
> AMD2400(32) 768Mb SUSE 10.0 | Falcon 14Mb TOS 4.02 | A4000 4Mb RISCOS 3.11
> AMD2600(64) 512Mb SUSE 10.0 | | RPC600 129Mb RISCOS 3.6


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com