Flush slash "\" in grep

I have a file with a line:

"H:\Check\WP_20140511_029.mp4"

along with other lines. I want to remove such lines indicating the directory in H:\Check. I tried

grep -v ".*H:\\Check.*" testout.txt > testout2.txt

But he did not delete these lines. What is wrong with my regular expression .*H:\\Check.*. regex101 shows that my regex matches the string correctly.

+4
source share
2 answers

You can use:

grep -v 'H:\\Check' testout.txt > testout2.txt

It is important to use single quotes to avoid over-escaping the backslash.

Using the equivalent double-quoted command will be as follows:

grep -v "H:\\\Check" testout.txt > testout2.txt

EDIT:

\\ - , . echo :

echo "H:\\Check"
H:\Check

echo 'H:\\Check'
H:\\Check
+8

-, grep - . * . Grep ( grepping , , , Hi there .*he.*, )

( , anubhava , ), - .

, , , H:\\Check.

( ), , C ( , ), , .

(, , , , , ), 4 . , , , - , 2, grep, .

, , , , - ( , ), .

: , . * .

+2

Source: https://habr.com/ru/post/1677391/


All Articles