On Sun, 12 Jan 2003 09:15:50 -0800
Mark Alexander <[EMAIL PROTECTED]> wrote:

> On Sat, Jan 11, 2003 at 05:56:16PM -0800, Jim C wrote:
> > I have a list of positive integers of which I only want the first one.
> > They are of arbitrary size. How can I cut the rest of them off?
> > I've been trying to write a regular expression for this using sed or awk.
> 
> #!/bin/sh
> LIST="42 666 1776 2001"
> echo $LIST | sed -e 's/^\([0-9]*\).*/\1/'
> 
> 

LIST="42 666 1776 2001"
echo ${LIST%% *} --> 42
or
LIST=(42 666 1776 2001)
echo ${LIST[0]} --> 42

both are about 5 times faster than a pipe with sed.

bye
jipe

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to