We help IT Professionals succeed at work.

grep for exact text

shanepresley
shanepresley asked
on
528 Views
Last Modified: 2010-05-18
Hello,

I'm looking to grep for some exact text in a file.  I want to print any lines that contain:

"- - ["

Without the quotes.  How would I structure a grep to look for that?

Thanks!
Comment
Watch Question

Top Expert 2005
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
fgrep -- "- - ["

Commented:
grep '--[' filename
Top Expert 2005

Commented:
yf_liang,
You cannot supply grep an unescaped pattern that begins with '-' ,
as it will be mistaken for an option [switch].   You should use the -e
option when supplying a pattern that starts with '-'.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.