Hacker News new | past | comments | ask | show | jobs | submit login
Grep is a beautiful tool (eriwen.com)
22 points by timexwatchninja on July 14, 2008 | hide | past | favorite | 8 comments



Is there something that has changed about grep in the past several years that makes mention of its existence news?


For the poor coders that have spent their whole lives in front of dumbed down IDE's... yes this is news. (Show some of these guys a pipe command and they won't see the implications. A sed style global regex search and replace action will be equally mystifying.)

Not everyone has succumbed to the power of the smug Unix weenies yet. And in any case... weekly diet of a few cool sed/grep/find/emacs/vi tricks is certainly in order for "Hacker News".


Ack is a beautiful tool.

http://petdance.com/ack/


I usually end up using

  function tfind {
    find . -name "*.$1" | xargs egrep -n "$2"
  }
 
  tfind extension searchpattern


I like ack better for searching code: http://petdance.com/ack/


NB: egrep (where available) has expanded regular expressions, including some extensions from perl.


My man pages tell me that egrep is the same as grep -E (--extended-regexp). There's also grep -P (--perl-regexp) which is even friendlier to Perl/Python/Ruby users, in that the parens and braces work the same way.


Or just go all the way and get pcregrep, then alias it to grep for convenience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: