This command is especially helpful if you want to use Tomcat-/Java-Keystore-Certificates with the Apache webserver. Use the -print_certs to print all the certificates and then cut the file and store each certificate in a single file.
openssl pkcs7 -in file.pem -print_certs -out certs.pem
Informations about the used arguments from the OpenSSL man page:
pkcs7
: PKCS#7 utility-in file.pem
: This specifies the input filename to read from or standard input if this option is not specified.-print_certs
: prints out any certificates or CRLs contained in the file. They are preceded by their subject and issuer names in one line format.-out certs.pem
: specifies the output filename to write to or standard output by default.