Monday, July 28, 2008

Simple Example of Unix "sed" command

Replacing all occurrences of rakesh to raka in file tst

sed s/rakesh/raka/ tst-1


Replacing all occurences of "raka" in old file tst-1 to "rakesh" in new file tst-2

sed s/raka/rakesh/ < tst-1 > tst-2


$ echo rakesh | sed s/rakesh/raka/

raka


$ echo I am rakesh | sed s/rakesh/raka/

I am raka


$ echo I am rakesh | sed 's/rakesh/raka/'

I am raka


s: Substitute Command

/../../ : Delimiter

rakesh : Regular Expression Pattern Search Pattern

raka : Replacement String


$ sed 's/\/tmp\/rk/\/tmp\/rk\/1/' tst-1

hi rakesh parwal

here is the directory /tmp/rk/1


No comments:

OCI - Attach Block Volume to Windows VM

Tip: Although creating and attaching Block Storage to a Windows VM is pretty straightforward (OCI documentation is pretty good for that), th...