I have a number of working scripts in place which out put to files, resulting in multiple files (examples)all over the place -example script below. Instead of this I would like to output the variables to an array - how do I do this and then access each individual variable, also if the array is empty I want a message to say that.
#!/bin/sh
finger -i|grep minutes > minutes
#filter users for selected conditions
awk '$7 > 45 { print $1 ; }' minutes > newmins
#Log all 45+ minutes idle
for USERS in `cat newmins`
do
w -h $USERS | grep -v root > temp
awk '{ printf ("%-32s %-14s %-32s\n", $1,$4,$7); }' temp >> $LOGFILE
done
exit
NOGSs-)
#!/bin/sh
finger -i|grep minutes > minutes
#filter users for selected conditions
awk '$7 > 45 { print $1 ; }' minutes > newmins
#Log all 45+ minutes idle
for USERS in `cat newmins`
do
w -h $USERS | grep -v root > temp
awk '{ printf ("%-32s %-14s %-32s\n", $1,$4,$7); }' temp >> $LOGFILE
done
exit
NOGSs-)