Reputation: 6846
I was requested to make a shell script to check for simple mistakes in files. I wanted to find, for each line if
(regex:) "[ ]\t" ever happens.
The problem is that grep is ignoring the \ and is taking "t" as a literal. I also tried writting the characters themselves in a file and asking grep to read it but it didn't work. Is there a way to find for the regex " \t" in files using any of the usual linux tools (like grep)?
I already tried:
grep -E --ignore-case --line-number --with-filename --file="b" file
(b contains: " ") and also:
grep -E --ignore-case --line-number --with-filename --regexp=" [\t]" file
Upvotes: 10
Views: 18170
Reputation: 21990
You can use perl regex with --perl-regex
option like
grep --perl-regex "\t"
Upvotes: 7
Reputation: 161884
You can use C-style string $'...'
grep $'\t' file.txt
Or sed
:
sed -n '/\t/p' file.txt
Upvotes: 18