The Archives

  • 10.Feb.09
    Some xargs scripts, shell | pfortuny | (1)
    Rafacas has already mentioned it, but xargs is sometimes much more useful than what it looks like. Two examples come to mind: Way too many files for rm or ls. It may well happen that a script has generated more than 10000 files in the same directory (it was your friend, not you, I know). If you try and rm * in there, you will be in trouble. Ditto if you simply want to count them with ls | wc -l. However, the following works: $ find . -type f -print0 | xargs -0 ls | wc -l (or rm instead of ...
  • 25.Oct.08
    Recursive grep in Solaris cmd | rafacas | (1)
    $ find . | xargs grep PATTERN In Solaris, the grep command does not have the -R (-r, --recursive) option which reads all files under each directory, recursively. The above command can be used to do the same in Solaris.