Skip to content

Instantly share code, notes, and snippets.

@rojenzaman
Last active December 13, 2020 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rojenzaman/b6d9b6821a66097c300b11ba8f1c7bd4 to your computer and use it in GitHub Desktop.
Save rojenzaman/b6d9b6821a66097c300b11ba8f1c7bd4 to your computer and use it in GitHub Desktop.
Save DNF installed packege log.
#!/bin/bash
script_dir=$(dirname $(readlink -f $0)) # script dir
function guide() {
echo "usage: ./`basename $0` [-u] [-s <app_name>]"
echo "-u update log"
echo "-s specific app log"
echo "-l list packages"
}
function updateLog() {
fileName="$(date +%d-%m-%Y)_after_update_installed"
echo -e "write app log\nMissing [CTRL+D] for exit from stdin\n"
stdText=$(</dev/stdin)
echo "$stdText" >> $fileName
echo -e " \n\nlog saved to $fileName"
}
function specific() {
fileName="$(date +%d-%m-%Y)_after_${appName}_installed"
echo -e "write app log\nMissing [CTRL+D] for exit from stdin\n"
stdText=$(</dev/stdin)
echo "$stdText" >> $fileName
echo -e " \n\nlog saved to $fileName"
}
while getopts ":us:l" opt; do
case ${opt} in
u ) updateLog ;;
s ) appName=${OPTARG}; specific ;;
l ) ls -1 $script_dir | grep -o -P '(?<=_).*(?=_)' | grep -o -P '(?<=_).*'|grep -v 'update' | awk 1 ORS=' ' ;;
: ) echo "Missing option argument for -$OPTARG <app_name>" ;;
esac
done
if [ "$#" -lt 1 ]; then
guide
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment