#!/bin/sh if [[ -n $1 ]]; then echo "File contains $(pdfinfo $1 | awk '/^Pages:/ {print $2}') pages" else total=0 count=0 for file in *.pdf; do count_file=$(pdfinfo $file | awk '/^Pages:/ {print $2}') echo "$count_file pages in $file" total=$(($total + count_file)) count=$((count + 1)) done echo " -> Total page count: $total -> Total files: $count -> Median: $(($total / $count)) " fi