>>>>> "n" == nimennor  <[EMAIL PROTECTED]> writes:

  n> Hi,
  n>    I have the following code repeated for about 100
  n>    directories, and in each directory there are about
  n>    200 files:

  n> cd /directory
  n> for file in *
  n> do
  n>          if [ -f $file ] ; then
  n>          echo -e "From - `date +%c`" >> Misc
  n>          cat $file >> Misc
  n>          rm -f $file
  n>             echo "" > /tmp/.misc
  n> fi
  n> done

Lift the date command of of the loop, and use "find . -type f -maxdepth 1"
instead of for file in * followed by the "test -f".

Something like this:-

msg="From - "date +%c`"
find /dir -maxdepth 1 -type f \
                -exec /bin/sh -c "( echo $msg ; cat {} ) >> Misc" \; \
                -print0 | xargs -0 /bin/rm -f

The bottleneck here is probably going to be the repeated exec of the
shell.   You could feed this through find2perl and modify the result
to remove the call to /bin/sh.


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to