Skip to content

Instantly share code, notes, and snippets.

@angel333
Last active November 19, 2016 14:53
Show Gist options
  • Save angel333/342c2cd3ccc79432aecdb11ee52cc0c5 to your computer and use it in GitHub Desktop.
Save angel333/342c2cd3ccc79432aecdb11ee52cc0c5 to your computer and use it in GitHub Desktop.
This one-liner will list packages that were explicitly installed by user.
#/bin/sh
# Description: Lists packages that were explicitly installed by user.
# Run this: curl -Ls goo.gl/RV7oiB | sh
export LC_ALL=C
MIN=2 # First is the OS installation
MAX=$(yum history | awk 'NR==4 { print $1 }')
yum history info $MIN..$MAX \
| grep '\sInstall\s' \
| awk '{ print $2 }' \
| awk '{ sub(/\-[^\-]+\-[^\-]+$/, ""); print }' \
| awk 'BEGIN { printf("\nyum install ") } { printf("%s ", $0) } END { printf "\n" }' \
| awk 'BEGIN { printf("To install packages installed on this machine, enter this command:") } { print $0 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment