find and replace command in one line using one command

Hi,

I have a entry in the file as

::BSNL GUJARAT::india::OUT::NAT::REWEL::POSTPAID::919426199995

if u see this, i have the delimiter as :: ,

all i want is to replace "::" as ":"

so how to do that..

pls help

thanks

echo "::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995" | sed -e 's#::#:#g'

Vino

Since you want to make this change ':' cannot be a legal character in the fields and so this will also work.

echo "::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995" | tr -s ':'

Be aware that this change will damage your data if ':' is a legal value, for example in a date.

by perl u can do the following

perl -pi -e 's/::/:/g' <filename>

This replaces ur '::' to ':' in the file directly.

i have a file.. which contains lot of paths ...

for eg.. file contains..

/usr/kk/rr/12345/1
/usr/kk/rr/12345/2
/usr/kk/rr/12345/3
/usr/kk/rr/12345/4
/usr/kk/rr/12345/5
/usr/kk/rr/12345/6
/usr/kk/rr/12345/7
/usr/kk/rr/12345/8

i want to replace /usr/kk/rr/12345/ with /usr/kk/yy/12555/

pls help

$sed 's/::/:/g' source file>destination file

actually u have replied for my ealier posts.. pls refer above, i am trying to rename a directory...

i can do with normal texts.. but i am not able to rename the directories pls help

Try this

This replaces "rr" with "yy" and replaces "12345" with "12555" in the entire file.

Regards,
Ragav.

wip_vasikaran,

Please don't hijack another ones thread and double post questions, continue here:

http://www.unix.com/unix-dummies-questions-answers/77908-how-use-sed-perl-command-find-replace-directory-file.html\#post302226884

its my own thread in fact.. since i was getting replies for old question..i reposted as a new query. anyways thanks for notifying me..

i tried with this solution it is working..

sed 's#usr/bin#/usr/txt#g'