I have file with line:
"H:\Check\WP_20140511_029.mp4"
along with other lines. I want to remove such lines indicating directory at H:\Check
. I tried
grep -v ".*H:\\Check.*" testout.txt > testout2.txt
But it did not delete those lines. Whats wrong with my regex .*H:\\Check.*
.
regex101 shows that my regex correctly matches the line.
You can use:
grep -v 'H:\\Check' testout.txt > testout2.txt
It is important to use single quotes to avoid excessive escaping of backslash.
Using double quotes equivalent command will be this:
grep -v "H:\\\Check" testout.txt > testout2.txt
EDIT:
\\
in double quotes is equivalent of a single backward slash due to shell expansion that happens in double quotes only. It is evident from these echo
commands:
echo "H:\\Check"
H:\Check
echo 'H:\\Check'
H:\\Check
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With