Mostly Linux & Python syntax notes and hyperlinks.

Friday, May 27, 2011

Linux: grep for $

This was harder than grep for tab.
I found instructions to escape the special character, but none of these
grep $ *
grep \$ *
grep "$" *
grep "\$" *
grep - $ *
grep "$" *
grep '$' *
egrep '$' *


worked until I read "Note that a $ sign loses its meaning if characters follow it" and remembered I was looking for a $ followed by a capital letter. So this works:

grep '$[A-Z]' *

but I still don't know how to find a $ by itself.

1 comment:

  1. Either
    grep "\\\$" *
    grep \\\$ *
    grep '\$' *

    work for me.

    Best regards

    Maxim

    ReplyDelete