Replace Text with sed

Hi ,

I�m working on Solaris 9 SPARC and I�m writing a Script to m�rror two disks..

I need to replace some text in a file ( /etc/vfstab ) .

For example:

/dev/dsk/c0t0d0s0 ==> /dev/md/dsk/d0

I just want to change the "/dev/dsk/" to "/dev/md/dsk/.

Thanks for your repsonse

Something like
sed 's!/dev/dsk/!/dev/md/dsk/!' /etc/vfstab > /etc/vfstab.new
will do the job for a simple substitution.

If the actual device filenames are changing too then more work will be required.

Cheers
ZB

An alternative :

echo "/dev/dsk" | sed 's/\/dev\/dsk/\/dev\/md\/dsk/'

This will not work for what the OP wants to do - which is change many entries within /etc/vfstab - you're just passing some static string to the sed. Also, the backslashed escaped slashes, whilst legal syntax, make the sed expression hard to read - replacing the delimiters with "!" (or anything else) increases the readability of the expression.

Cheers
ZB

I must recommend http://www.selectorweb.com/sed_tutorial.html
It was a big help for me when I was teaching myself how to use sed. The original question has been answered but I believe that the sed tutorial is a good resource for continuing education.

-Seg

@ zazzybob

Thanks a Lot it works great..