Vamsi Pavan’s Place

When curiousity outbursts …..

Typical Unix/Linux recursive search commands

June 9th, 2008 · No Comments · Algorithms, Linux

The Typical one is - to find the files with some pattern recursively in a given directory.

$ find path/to/dir -name “*.html”

You can replace the “*.html” to your own filename pattern.

Another one is, in addition to above I need the text lines inside those files starting with letter t.


$ find path/to/dir -name “*.html” -exec grep “^t” {} \;

Another version with output filename plus greped text content is

$ find path/to/dir -name “*.html” | xargs grep “^t”;

-exec and xargs are the two helped commands to extend the main command functionality.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

Tags: ···

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment