Skip to content

Instantly share code, notes, and snippets.

@larsks
Last active December 19, 2015 19:49
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 larsks/6008833 to your computer and use it in GitHub Desktop.
Save larsks/6008833 to your computer and use it in GitHub Desktop.
#!/bin/awk -f
# This script expects a list of concatenated certificates on input and
# produces a collection of individual numbered files each containing
# a single certificate.
BEGIN {incert=0}
/-----BEGIN( TRUSTED)? CERTIFICATE-----/ {
certno++
certfile=sprintf("cert-%d.crt", certno)
incert=1
}
/-----END( TRUSTED)? CERTIFICATE-----/ {
print >> certfile
incert=0
}
incert==1 { print >> certfile }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment