#!/bin/bash
[ "$#" -ne 3 ] && echo "usage: $0 file h|t N" && exit 1
file=$1
mode=$2
num=$3
case "$mode" in
  h) head -n "$num" -- "$file" 2>/dev/null ;;
  t) tail -n "$num" -- "$file" 2>/dev/null ;;
  *) echo "mode must be h or t" ; exit 1 ;;
esac

