YASS (yet another shell script)

Chris Torek chris at umcp-cs.UUCP
Tue Mar 18 09:42:45 AEST 1986


In article <860 at decuac.UUCP> avolio at decuac.UUCP (Frederick M. Avolio)
writes:

>In article <153 at sci.UUCP>, raymund at sci.UUCP (Raymund Galvin) writes:
>> The following alias will print any single line from a text file:
>>	alias line 'awk NR==\!:1 \!:2-$'
>> The following alias will print a range of lines from a text file:
>>	alias list 'awk NR==\!:1,NR==\!:2\{print\ NR\":\"\$0\} \!:3-$'
>The problem with the awk versions is that they process the whole file,
>even after you are no longer interested in output.

Not if you do it right:

	alias line "awk 'NR == \!:1 { print; exit }' \!:2*"
	alias list "awk 'NR == \!:1, NR == \!:2 { print NR "'":" $0 } NR == \!:2+1 { exit }'"' \!:3*"
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.sources.bugs mailing list