[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reading the first colums of text file
From: |
Brian J. Murrell |
Subject: |
Re: reading the first colums of text file |
Date: |
Sat, 03 Feb 2007 23:09:50 -0500 |
On Sat, 2007-02-03 at 10:59 -0700, Bob Proulx wrote:
>
> echo one two three four five six seven | awk '{print$2,$NF}'
> two seven
That one always drives me nuts. Why fork/exec for such a heavy process
for something bash can do itself:
cat $file | while read column1 rest; do
echo $column1
done
Or if you need the data in the calling shell's context:
while read column1 rest; do
# the goodies are in $column1
done < <(cat $file)
Probably a dozen other ways to do it too.
b.
--
My other computer is your Microsoft Windows server.
Brian J. Murrell
signature.asc
Description: This is a digitally signed message part