Find|xargs like a boss (Real Example)
r-bloggers.com
r-bloggers.com
There's no need to use xargs, and pipe to sh in this scenario. The same functionality can be achieved by using only find:
PROCS=8;cuffs=`which cufflinks`;find `pwd` -name 'accepted_hits.bam' -type f -exec qsub -l ncpus=$PROCS -- $cuffs -p $PROCS -o {}-cufflinks -g genes.gtf {} \;>xargs can run a given number of jobs in parallel, but has no support for running number-of-cpu-cores jobs in parallel.
>xargs has no support for keeping the order of the output, therefore if running jobs in parallel using xargs the output of the second job cannot be postponed till the first job is done.
find . -mindepth 1 -maxdepth 1 -type d | awk 'BEGIN {FS="./"}; {print $2}' | xargs -d '\n' tar czf backup1.tar
Note that you'll have to change $2 to the correct column number for the name field depending on your output.An easier way to accomplish the original command uses globbing (like in bash):
tar czf backup1.tar */