JessiBaughman

Find Packages Installed with apt-get

Sep 6th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.84 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # apt-list - A script to show packages installed with apt-get
  4. #
  5. # Usage: apt-list <installed|removed|kept>
  6. #
  7. # G+ Post: https://plus.google.com/+JessiBaughman/posts/7USUQfh3y7y
  8. # Created by: Jessi A. Baughman
  9. # Last Modified: 2018-09-06
  10.  
  11. if [[ $1 == "installed" ]];then
  12.     awk '$0 ~ "install " {if ($4 != "install" && $4 != "-y" ) print $4}' /var/log/apt/history.log | awk '!x[$0]++' | sort
  13. elif [[ $1 == "removed" ]];then
  14.     awk '$0 ~ "remove " {if ($4 != "remove") print $4}' /var/log/apt/history.log | awk '!x[$0]++' | sort
  15. elif [[ $1 == "kept" ]];then
  16.     awk '$0 ~ "install " {if ($4 != "install" && $4 != "-y") print $4} $0 ~ "remove " {if ($4 != "remove") print $4}' /var/log/apt/history.log | awk '{!seen[$0]++};END{for(i in seen) if(seen[i]==1)print i}' | sort
  17. else
  18.     echo
  19.     echo "Usage: apt-list <installed|removed|kept>"
  20.     echo
  21. fi
Add Comment
Please, Sign In to add comment