Last active
November 9, 2021 11:00
-
-
Save JonLevin25/8decc7dce9065ecba75911eb158dde94 to your computer and use it in GitHub Desktop.
Debian: Extract packages installed to script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Options | |
#output_file=~/debs_install.log | |
output_file=~/debs_install.sh | |
# filter logs for active install commands | |
# columns: $1=install date, $2=install time, $4=pkg id, $5="<none>" (?), $6=version | |
awk_cmd='/ install /{print "apt install " $4 " # originally installed " $1}' | |
#### Make the output a runnable script (in order | |
gunzip -c /var/log/dpkg.log.2 | awk "$awk_cmd" >1 $output_file | |
cat /var/log/dpkg.log.1 | awk "$awk_cmd" >> $output_file | |
cat /var/log/dpkg.log | awk "$awk_cmd" >> $output_file | |
#### Get output from dpkg logs - newest first | |
# tac /var/log/dpkg.log | grep " install " > $output_file | |
# tac /var/log/dpkg.log.1 | grep " install " >> $output_file | |
# gunzip -c /var/log/dpkg.log.2 | grep " install " | tac >> $output_file | |
#### Get output from dpkg logs - oldest first | |
#gunzip -c /var/log/dpkg.log.2 | grep " install " > $output_file | |
#cat /var/log/dpkg.log.1 | grep " install " >> $output_file | |
#cat /var/log/dpkg.log | grep " install " >> $output_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment