how to delete the lines containing "./."
Hello everyone,
I am new to linux, I know how to delete the one special character in linux, but i don't know how to delete the lines containing character like "./.". hopefully someone could give some instruction. Thanks a lot |
This will preview the changes.
Code:
sed '/\.\/\./d' name_of_your_file Code:
sed '/\.\/\./d' name_of_your_file > new_file Code:
sed -i '/\.\/\./d' name_of_your_file |
Quote:
Not only ./. You'd have to escape . as well: Code:
sed '/\.\/\./d' file |
Thanks a lot, kabamaru, looks like the last one works
|
Quote:
|
Quote:
|
To get around conflicts with "/" in sed, you can use a different delimiter.
In the substitution command, you can simply use any ascii character (except for newline and null) instead of the slash. I generally like to use "|" myself. Code:
sed 's|.*\./\..*||' file #for demonstration purposes, it leaves a blank line behind Code:
sed '\|\./\.|d' file Code:
sed '\|[.]/[.]|d' file http://www.grymoire.com/Unix/Sed.html http://sed.sourceforge.net/grabbag/ http://sed.sourceforge.net/sedfaq.html http://sed.sourceforge.net/sed1line.txt A couple of regular expressions tutorials: http://mywiki.wooledge.org/RegularExpression http://www.grymoire.com/Unix/Regular.html |
All times are GMT -5. The time now is 04:55 PM. |