> On Saturday 11 January 2003 08:56 pm, 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.

you don't specify the format of  the integers.  are they space separated
and all on one line?  or are they line separated (each integer on
its own line)?

are there blank spaces (if the first) or blank lines (if the second) before
the first integer?

or are they in some other format?  you say they're arbitrary size, so does
that mean they aren't in some fixed column format?

if they're one integer to a line, then head (for the first), tail (for the 
last), or some combination of head and tail (for anything in between)
will get you the integer you want.

if they're delimited by something (spaces, commas, colons, whatever),
then cut -f <fldnumber> -d "<delimiter>"  might help.  otherwise,
well, sed, awk, or some custom program in your favorite language.

if there are blank lines or blank fields before the first number, then
some sort of bash while loop would be needed to ignore the
blank lines or blank fields, print the first non-blank field, and then
exit the loop.

tiger

-- 
Gerald Timothy Quimpo  tiger*quimpo*org gquimpo*sni-inc.com tiger*sni*ph
Public Key: "gpg --keyserver pgp.mit.edu --recv-keys 672F4C78"
                   Veritas liberabit vos.
                   Doveryai no proveryai.

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

Reply via email to