#!/bin/bash _pdffetchusage() { cat << EOF curl -> pdftotext -> stdout as text Usage: pdffetch <options> [url] Option: -h | --help: Print this help pdftotext options: see \`man pdftotext\` Dependency: pdftotext curl EOF } if [ "$1" != '-h' ] || [ "$1" != '--help' ]; then tmpfile=$(mktemp) curl -Lo ${tmpfile} "${@:$#}" && pdftotext "${@:1:$#-1}" ${tmpfile} - # "${@:$#}" : last argument # "${@:1:$#-1}" : all arguments except last one trap "rm ${tmpfile}" 0 else _pdffetchusage exit 1 fi