Women in Technology

Hear us Roar



Article:
  Electronic Archaeology
Subject:   another alternative to find/grep
Date:   2003-05-07 14:01:28
From:   anonymous2
"find . -name \*.c -exec grep foo \;" is quite slow and cumbersome to type. "grep -r foo ." is GNU only and you can't restrict which files it sees. You can use "find . -name \*.c | xargs grep foo" to run almost as fast as the latter with the full expressive power of the former and xargs is a standard tool. Use xargs in any pipeline to invoke the command given as its argument using arguments taken from stdin. In this case, invoke grep foo with files produced by find.