#!/bin/bash
#creates file with a list of all packages installed by date
#append all info from archived logs
i=2
mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
nlogs=$(( $mycount + 1 ))
while [ $i -le $nlogs ]
do
if [ -e /var/log/dpkg.log.$i.gz ]; then
zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/packagetmp.txt
fi
i=$(( $i+1 ))
done
#Next append all info from unarchived logs
i=1
nulogs=$(ls -l /var/log/dpkg.log.* | wc -l)
nulogs=$(( $nulogs - $nlogs + 1 ))
while [ $i -le $nulogs ]
do
if [ -e /var/log/dpkg.log.$i ]; then
cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/packagetmp.txt
fi
i=$(( $i+1 ))
done
#Now append current log
cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/packagetmp.txt
#sort file data by date
sort -n $HOME/pkgtmp.txt > $HOME/packageinstalls.txt
rm $HOME/packagetmp.txt
exit 0
#creates file with a list of all packages installed by date
#append all info from archived logs
i=2
mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
nlogs=$(( $mycount + 1 ))
while [ $i -le $nlogs ]
do
if [ -e /var/log/dpkg.log.$i.gz ]; then
zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/packagetmp.txt
fi
i=$(( $i+1 ))
done
#Next append all info from unarchived logs
i=1
nulogs=$(ls -l /var/log/dpkg.log.* | wc -l)
nulogs=$(( $nulogs - $nlogs + 1 ))
while [ $i -le $nulogs ]
do
if [ -e /var/log/dpkg.log.$i ]; then
cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/packagetmp.txt
fi
i=$(( $i+1 ))
done
#Now append current log
cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/packagetmp.txt
#sort file data by date
rm $HOME/packagetmp.txt
exit 0