Reputation: 187
I want to grep \" as following text in file(abc) like:
$egrep -n "^\"$" abc
"CO_FA_SC_600212","2","\"HSE 48\" 48 CHIVALRY AVE"
But its not appearing how could i use egrep or grep to get the line.
Upvotes: 2
Views: 12863
Reputation: 2582
Here are two alternatives:
grep -n "\\\\\"" filename
grep -n '\\"' filename
\\
act as a single \
, and "
was escaped by \
, so \\"
is passed to grep
. \
is taken literally, so \\"
is passed to grep
3
and 4
can be verified by echo "\\\\\""
and echo '\\"'
Upvotes: 1
Reputation: 12658
grep -F 'special char' filename
will search the lines which has special characters.
grep -Fn 'special char' filename
gets the line number too.
man grep says,
-F, --fixed-strings
: Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched
Upvotes: 1