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)
Showing posts with label sed. Show all posts
Showing posts with label sed. Show all posts
Wednesday, July 1, 2009
Linux:Shell:Bash: how to search slash or backslash by sed
Thursday, April 9, 2009
Linux:shell:BASH: How to delete one line by sed
If you want to delete one line containing one word "ThisWord" by sed, then you can do in the way:
sed -i "/ThisWord/d" YourTextFile.txt
Note, here '-i' is to delete it from the original file. Without it, sed only prints the file on screen. So before using '-i', make sure you are doing correct things.
Subscribe to:
Posts (Atom)
