Last active
December 13, 2020 22:38
Save DNF installed packege log.
This file contains hidden or 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
#!/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