Grep options

Dan Nicholson dbn.lists at gmail.com
Mon Oct 30 10:33:58 PST 2006


On 10/30/06, Ken Moffat <ken at linuxfromscratch.org> wrote:
>
> > 2) How do I list in the zone.tab only the third column (the timezone one)?
> >
>  I'm not sure I understand what you want to do.  No doubt there
> are many ways of listing only the third column, but something like
>  cat zone.tab | awk '{ print $3 }'
> will print the whole file's zones.  So, if you want to limit this to
> the zones in a particular country, such as e.g. Greenland (to get
> multiple entries)
>  grep '^GL' zone.tab | awk '{ print $3 }'
>
>  These sort of general questions are probably better directed to
> lfs-chat, please reply there.  Thanks.

Just had to jump in here. awk is all you need in this case because it
does regex searches sort of like sed syntax.

awk '/^GL/{ print $3 }' zone.tab

--
Dan



More information about the lfs-support mailing list