YASS (yet another shell script)

Frederick M. Avolio avolio at decuac.UUCP
Tue Mar 18 07:13:51 AEST 1986


In article <153 at sci.UUCP>, raymund at sci.UUCP (Raymund Galvin) writes:
> In article <620 at ssc-vax.UUCP>, aims at ssc-vax.UUCP (John Daley) writes:
> > This is a 'simple' little shell script I whipped up, out of need, to
> > print a specific line of a specific file. 
> 
> Better?  I dont know.  I dont have access to B shell. 
> 
> 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. So, 

	line 10 /etc/termcap

does take a while after printing line #10.  

John's script does use the Bourne Shell, but his basic algorithm (head
piped to tail) is usable as an alias, and is quicker than using awk
for the above-mentioned reasons.  (5 times faster to *return* on
/etc/termcap ... rough timing.)
-- 
Fred @ DEC Ultrix Applications Center
UUCP: {decvax,seismo,cbosgd}!decuac!avolio       INET: avolio at decuac.DEC.COM



More information about the Comp.sources.bugs mailing list