Re: OT: running a command on many files in many subdirectories
On Wed 29 Jan 2003 08:37:35 +0000(+0100), Jean-Marc V. Liotier wrote:
>
> files=`find . -name '*.tif' -print | wc -l | tail -c 2 | head -c 1`
> cpu=`grep processor /proc/cpuinfo | wc -l | tail -c 2 | head -c 1`
If I understand you, you're using "tail -c 2 | head -c 1" to separate the number of lines from the whitespace in the "wc -l" output. In fact it appears to extract just the last digit. You could use "awk '{print $1}'" to print the number on its own.
> nnumber=`expr $files / $cpu`
I think you would want to round up nnumber to avoid one processor running two xargs processes:
nnumber=`expr \( $files + $cpu - 1 \) / $cpu`
--
Cheers,
Clive
Reply to: