Re: SCRIPT: head

From: Michele Andreoli (m.andreoli@tin.it)
Date: Mon Nov 06 2000 - 14:01:09 CET


On Mon, Nov 06, 2000 at 01:05:42PM +0100, Jochen Cichon nicely wrote:
> OK, I've tested something around mu. And I needed some HEAD command...
> But that is only on TCL (which I noticed much later :( )
> because I used only the first two disks...
> So how to get head...
>
> So i've used awk...
>
> ---------- cut here ------------
> #!/bin/ash
>
> awk -v max=$2 '
> begin { i=0 }
> { if (i < ((max=="")?10:(max<0)?-1*max:max)) print $0; i++; }' $1
> ---------- cut here ------------
> and it's only 110 Bytes to 635 Bytes :)
> And supports...
> awk file # 10 Lines
> awk file 2 # 2 Lines
> awk file -2 # 2 Lines
>
> So have fun...
>
> PS: I like small scripts... for mu
>

Thank you. You call awk in a shell script; this requires much
memory. It is better to change interpreter in the head of the
script "#!". I will try, in future, to improve your script.

Michele

-- 
"I'd like to conclude with a positive statement, but I can't remember any.
Would two negative ones do?"			-- Woody Allen
---------------------------------------------------------------------
To unsubscribe, e-mail: mulinux-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: mulinux-help@sunsite.auc.dk


This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:16 CET