Skip to content

Instantly share code, notes, and snippets.

@AdamJCavanaugh
Last active April 13, 2020 13:44
Show Gist options
  • Select an option

  • Save AdamJCavanaugh/c356f3531eeb93d0645a55404b14a434 to your computer and use it in GitHub Desktop.

Select an option

Save AdamJCavanaugh/c356f3531eeb93d0645a55404b14a434 to your computer and use it in GitHub Desktop.
Bash snippets
# Prompt
PS1="\u@\h:\w>"
# timestamp
$(date +%y%m%d_%H%M%S)
# Unzip and rename appeal.xml by AppealNumber from manifest.txt
for file in $(ls -1 .); do
appealNum=$(unzip -p ${file} 'manifest.txt' | awk -F '=' '/AppealNumber/ {print $2}')
unzip ${file} appeal.xml && mv appeal.xml ${appealNum}-appeal.xml
done
# Count files by extension
ls -1 . | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $2,$1}'
# Count files by date
find . -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
# OpenSSL get cert
openssl s_client -showcerts -connect www.example.com:443
# .cer to PEM
openssl x509 -in ${file}.cer
# .key to PEM
openssl rsa -in ${file}.key
# .p7b to PEM
openssl pkcs7 -inform der -in ${file}.p7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment