Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2002-04-02 22:51:24
Size: 822
Editor: anonymous
Comment: missing edit-log entry for this revision
Revision 3 as of 2008-02-19 15:39:23
Size: 838
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

CategoryComputingTips > FileUtilsCompTips
Line 19: Line 22:

----
CategoryComputingTips

CategoryComputingTips > FileUtilsCompTips

FileUtils Tips

Using find

  • find is really useful and once you get the hang of it you probably want to use the -exec thing but this it isn't hugely clear that you have to escape the terminating ; from the shell. You use {} to substitute for the name of the file found.

find . -name '*.c' -exec echo foo {} \;
  • You can also use xargs for this to save spawning one process for each file.

find . -name '*.c'|xargs grep foobar
  • When your filenames have spaces in and you want to use find and xargs together use the -print0 and -0 flags to null terminate the strings find passes to xargs and conversely so xargs knows it's gettings null terminated input.

find . -name '*.c' -print0|xargs -0 grep foobar

TheEarthWiki: FileUtilsCompTips (last edited 2008-02-19 15:39:23 by localhost)