Wednesday, July 1, 2009

Linux:Shell:Bash: how to search slash or backslash by sed

It is tricky to search (or replace) signs slash '\' or backslash '/' by sed. By searching internet, I found 2 approaches:

1. Put the command line of sed to a file called my.sed:

/D\\O/p

(this will print a line containing 'D\O')

2. Another way is to use single quote instead of double one in your shell command line:

sed -n '/D\\O/ p' myfile.txt

(-n is prevent from printing)

No comments:

Locations of visitors to this page