Need utils: head,yes,& nroff (-man) for SysV2 (CCI 2.21or2.22)

Lawrence Keith Blische lkb at theceg.UUCP
Tue Jun 28 23:05:37 AEST 1988


>From article <8171 at brl-smoke.ARPA>, by gwyn at brl-smoke.ARPA (Doug Gwyn ):
> In article <6007 at hqda-ai.ARPA> jay at hqda-ai.ARPA (Jay Hiser) writes:
>>head: the opposite of 'tail'.
> 
> if [ $# -eq 0 ]
> then	n=10
> else	case $1 in
> 	[0-9]*)	n=$1;	shift;;
> 	*)	n=10;;
> 	esac
> fi
> exec sed -e ${n}q $*

I don't want to start the "whose's head is best" :-) war but
the following version seems to better adhere to the BSD SYNOPSIS 
given in my Berkeley (4.3) doc for head(1):

	head [-count] [file ...]

It also overcomes a descrepency between my SysV sed(1) man page
(which indicates that sed takes multiple input files) and reality
(which says it dosen't :-( ).

: Bourne Shell Script
if [ $# -eq 0 ]
then	sed 10q
else	case $1 in
	-[0-9]*)	n="`echo $1|cut -c2-`"
			shift;;
	*)		n="10";;
	esac
	for file in $*
	do
		sed ${n}q $file
	done
fi
----------------------------------------------------------------------
Larry Blische			      ...!cp1!sarin\
The Computer Engineering Group, Inc.		    !wb3ffv!theceg!lkb
+1 301 282 5876 (9-5 ET)	         ...!aplcen/



More information about the Comp.unix.questions mailing list