From: Jochen Cichon ([email protected])
Date: Wed Nov 08 2000 - 09:28:04 CET
> You can make your script tinier :
> #/bin/ash
> awk -v max=$2 '
> { if (NR < ((max=="")?10:(max<0)?-1*max:max)) print $0; }' $1
> NR is the number of records read so far.
HM there is a mini Bug :)
If you use a number (head file 2) it only prints one LINE :(
so it must be
... (NR <= ((max ....
> #/bin/ash
> awk -v max=$2 '(NR<((max=="")?10:(max<0)?-1*max:max)) { print $0 }' $1
Works also (with that mentioned mini bug :) )
> With Michele's advice, it could be something like
> #/bin/awk -f
> (NR<max=((argv[2]=="")?10:(argv[2]<0)?-1*argv[2]:argv[2])) { print $0 }
Hm that doesn't work. :( But i don't know why.
> >I like small scripts... for mu
> Small is beautiful!
Jep. The last head script (head3 :) is only 79 BYTES. And the first one is
110 bytes... So ... go ahead :)
Jochen...
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:16 CET