I have the following regular expression to match a phone number. The regular expression works (123)123-123, but I am puzzled by the last result.
user@host: grep -l -v -f *.txt -E "(\d{3})-\d{3}-\d{3}"
f2.txt
f3.txt
f4.txt
grep: (\d{3})-\d{3}-\d{3}: No such file or directory
Why is grep searching the regular expression?
Here is the ls:
user@host:/tmp# ls
f1.txt f2.txt f3.txt f4.txt
The grep usage is
Your command expands to
which is equivalent to
which is "use the file
f1.txtas a file containing patterns, and search the filesf2.txt,f3.txt,f4.txtand(\d{3})-\d{3}-\d{3}. Apply options-l,-vand-Eeverywhere."Maybe you meant
instead?
The relevant part of the man page reads as follows:
Side note: if you use
-E, you have to escape literal parentheses. Also,\dis not supported as far as I can tell, so you'd have to use eitheror