Slow bash script
The following script seems to run abnormally slow on a 400Mhz Sarge system,
getting only about one iteration per second in the while loop. It extracts
md5sums from a 180k Packages file and makes an indices file. I've narrowed down
the slowdown to the lines in the while loop starting with "search=..."
The system is otherwise unloaded and not swapping when I see the slowdown.
Thanks in advance for any ideas or clues about the slowdown, or about how to
speed up the loop.
mkdir /mnt/install/debian-multimedia/indices
find /mnt/install/debian-multimedia/dists/etch/main/ |grep Packages |grep -v z
|xargs cat| \
while read inputline
do
search=`echo $inputline | grep Filename |cut -f 2 -d ' '`
if [ "$search" != "" ]
then
filename=$search
fi
search=`echo $inputline | grep MD5 |cut -f 2 -d ' '`
if [ "$search" != "" ]
then
nextline="$search $filename"
echo $nextline
fi
done |gzip >/mnt/install/debian-multimedia/indices/md5sums.gz
Reply to: