#!/usr/bin/env etsh : : etsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: d63cea797446d24c87a83c1cbb422a989d7730d4 $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : : : " NAME " : " ncat - concatenate and print files w/ line numbers " : : " SYNOPSIS " : " ncat [- | file ...] " : : " DESCRIPTION " : " For each line in any specified file (or the standard input), " : " ncat writes the line number, followed by a tab character and " : " then the line itself to the standard output. If a file is " : " not specified or is specified as `-', ncat attempts to read " : " lines from the standard input. " : : " The primary reason for ncat is because cat(1) is really not " : " supposed to print files w/ line numbers as in `cat -n file'. " : " However, this is ncat, not cat(1). Thus, printing files w/ " : " line numbers is a perfectly legitimate thing to do. " : : " SEE ALSO " : " R. Pike and B.W. Kernighan, " : " Program Design in the UNIX Environment, 1984: " : " http://harmful.cat-v.org/cat-v/unix_prog_design.pdf " : : >>$0'' <'' ; killer $0 ncat if $# != 0 goto Loop awk '{ print NR "\t" $0 }' <- ; exit : : " Process each argument until one of the following occurs: " : : " 1) If $1 is bad, exit w/ a `syntax error'. " : " 2) If $1 cannot be opened, exit w/ a `cannot open' error. " : " 3) When no arguments remain, exit w/ a status of zero. " : : Loop : >>$1'' <'' if X$1 = X- goto FD0 if -f $1'' awk '{ print NR "\t" $0 }' <$1'' ; shift if $# = 0 exit goto Loop : FD0 awk '{ print NR "\t" $0 }' <- ; shift if $# = 0 exit goto Loop