#!/bin/bash # merge multiple pdfs into one args=$(($# - 1)) if [[ $# = 0 ]] || [[ $args = 0 ]]; then echo "usage: ${0##*/} input.pdf [input2.pdf ..] output.pdf" exit 0 fi gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${!#} -sDEVICE=pdfwrite "${@:1:$args}"