As expected for this list, fast and precise reply from Julien Soula
(soula_at_lifl.fr) !
The "while" loop is executed in a child process and all variables
are lost at the end of the loop. Bellow, the same script to read
lines from a file with correction and improvement.
Tanks again, Julien !
------------------------------------------------------------------
#!/bin/bash
#----------> Enhanced
#
TMPFILE="RPM.lst"
declare -i RPMCNT=0 # Array index
declare -a RPMLIST # Array for RPM list
#
rpm -qa > $TMPFILE
#
while read LINE
do
let RPMCNT=RPMCNT+1 # Update index
RPMLIST[$RPMCNT]=$LINE # Update array
printf "%4i %4i %-s\n" $RPMCNT ${#RPMLIST[*]} \
${RPMLIST[$RPMCNT]}
done < $TMPFILE
#
printf "\nRPM count: %4i %4i\n" $RPMCNT ${#RPMLIST[*]}
if [ -f $TMPFILE ]; then rm -f $TMPFILE; fi
exit 0
------------------------------------------------------------------
Jean-Pierre Vorlet Jean-Pierre.Vorlet_at_unifr.ch +41 26 300 7218
System Manager University of Fribourg Switzerland
Received on Thu Sep 12 2002 - 10:47:08 NZST