#! /bin/bash -ue
# Last edited on 2025-05-04 22:43:29 by stolfi

# Shows the first ${top} and the last ${bot} lines of the ${file} on stderr.

top="$1"; shift
bot="$1"; shift
file="$1"; shift

printf "\n"
sum=$(( ${top} + ${bot} ))
len=`cat ${file} | wc -l`
# printf "    sum = ${sum}  len = ${len}\n" 1>&2
if [[ ${sum} -ge ${len} ]]; then
  cat ${file} | sed -e 's:^:    :g' 1>&2 
else
  head -n ${top} ${file} | sed -e 's:^:    :g' 1>&2 
  echo "    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ." 1>&2 
  tail -n ${bot} ${file} | sed -e 's:^:    :g' 1>&2 
fi
printf "\n"
