Last active
October 25, 2023 15:10
-
-
Save jrwarwick/8d05763527c66c52a5860c4a9ca83ee7 to your computer and use it in GitHub Desktop.
Potpourri of handy shell one-liners/gems/nuggets for really specific tasks
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
# just keep running count of seconds gone by, printing to console periodicially. | |
# Useful as rough "stopwatch" when you need to prove to your netadmin that your ssh sessions are getting disconnected regularly. | |
BEGIN=$(date "+%Y%m%d%H%M%S") ; while [ 1=1 ] ; do echo "$(( $(date '+%Y%m%d%H%M%S') - $BEGIN ))" ; sleep 300 ; done | |
# Quick and dirty terminal-based test of (HTTPS) SSL connectivity and get the cert expiry properties | |
echo | openssl s_client -showcerts -connect foohost.bardomain.tld:443 | openssl x509 -noout -dates | |
## Thought: what belongs in here versus .profile as an alias/function? | |
## Probably anything that you aren't going to call often enough to warrant spending neurons on memroizing even the alias/func name. | |
## in which case most of what follows should actually go elsewhere. | |
# quick and dirty backup-this-file-right-here-right-now. prime use case: right before you modify any config files in /etc/* | |
function bup() { cp -pv $1 $1.$(date +%Y%m%d) ; ls -lFth $1* ; } | |
alias urldecodepipe='sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b"' | |
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}" ; } | |
function catalina_api_uri_watch () { watch '( grep "\-api" $( ls -rt /var/log/tomcat/*access* | tail -3 ) ; echo -e "\n" ) | cut -f 4,7 -d " " | tail -25 | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b"' ; } | |
# Specifically for automated signing actions, on a secure host, and requires env var AUTOMATION_GPG_USERID | |
alias gpg_sign_file="cat $HOME/.gnupg/private-keys-v1.d/${SECDOMAIN_FILENAME_TAG}.secret.pgp.passphrase | gpg2 --passphrase-fd 0 --batch --local-user \$AUTOMATION_GPG_USERID --armor --sign " | |
# Extract the short Key ID from a public key file, *without* importing to keyring. | |
gpg2 --dry-run --import foo.public.pgp.asc 2>&1 | sed 's/[ ]\{1,\}/ /g' | grep 'gpg: *key' | cut -f3 -d' ' | sed 's/:$//' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment