grep/matching help with long listing of directories

How do I get this to work?

cat somefile | grep "-rw-r--r--  1 root  wheel       287 Sep 10 15:12 shells~" 

This is the the desired output

-rw-r--r--  1 root  wheel       287 Sep 10 15:12 shells~

I basically want an exact match of the line I am grepping for, the special characters and spaces are giving me errors. Or is there another method I could use?

Try single quotes in place of double quotes.

Yea I tried that to no avail, still getting errors.

Congratulations, you're the proud recipient of a UUOC Award. :wink: Remember, whenever you write 'cat filename | command' you can almost almost always rewrite this in a simpler way as 'command < filename'.

I'm guessing(since you didn't say) that it's complaining about bad parameters. It thinks your string is a switch since it starts with -. If you want to tell grep that the following option is a parameter and not a switch, you can add -- before it.

grep -- "-rw-r--r--  1 root  wheel       287 Sep 10 15:12 shells~" < filename

Thanks Corona688 , I missed the leading hyphen. Now if the OP had posted the error message ...

This should be faster without the inward redirect.

grep -- "-rw-r--r--  1 root  wheel       287 Sep 10 15:12 shells~" filename

thanks guys!