#!/bin/sh
#
# nth - display nth line of each file

usage() {
  printf '%s\n' "usage: $(basename "$0") NUM FILE [FILE ..]" >&2
  exit 1
}

if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ -z "$1" ]; then
  usage
fi

isnum "$1" || usage
nth="$1"
shift

awk "{ if (FNR == $nth) { print; nextfile; } }" "$@"
