#!/bin/sh m=10 useage () { echo "Usage: head [OPTION]... [FILE]..." echo -e "\t-n,-[0-9]+\tprint first NUMBER lines instead of first 10" exit 1 } while [ "$1" ] ; do case "$1" in -n) m="$2" ; shift ; shift ;; -[0-9]*) m=${1#-}; shift ;; -*) useage ;; *) break; esac done exec grep -m$m "" $*