Grep options

Ken Moffat ken at
Mon Oct 30 09:58:22 PST 2006

On Mon, Oct 30, 2006 at 05:16:22PM +0100, Luca wrote:
> Hi all!
> I have two questions about grep (tried various times looking at the docs
> etc...).
> I have unpacked glibc and in the source dir under the localedata there
> is the SUPPORTED file and under the timezone dir there is the file.

 As a general rule, in the shell you string different commands
together to do something, you don't expect one tool to do
everything.  Everybody has their own preferred ways of doing that.
> Taken these two files which options should I pass to grep for
> 1) in the SUPPORTED file lists all the locales until the '/' delimiter
> example, I use the it_IT.utf8 locale,
> the relative SUPPORTED line is it_IT.UTF-8/UTF-8 \ and the locale -a
> output is it_IT.utf8, how do I manage to have grep to output the exact
> form in which the locale is used in the $LANG variable (that's the
> output given by locale -a) not using the 'locale -a' command?
> I intend how do I transform the it_IT.UTF-8/UTF-8 \ to the form
> it_IT.utf8 and for example the it_IT at euro/ISO-8859-15 \ in it_IT at euro
> and it_IT.iso885915 at euro?

 I think you'll find that the correct way to specify locales is
it_IT.UTF-8 NOT it_IT.utf8, even though 'locale -a' uses the other
style.  This has come up before in the lfs or blfs archives, I can
remember someone, probably Alexander, supplying the detail.

 To strip everything from the '/' onwards, preferred tools are
probably 'cut', or 'sed' if you want to look flash.

 And if you really do want to convert the data in the SUPPORTED file
to the other style, sed (or perhaps perl, if the transformations
become interesting), but you'll probably need to search for the rules
on what should  follow '.utf8@'. 

> 2) How do I list in the 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 | 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' | awk '{ print $3 }'

 These sort of general questions are probably better directed to
lfs-chat, please reply there.  Thanks.

das eine Mal als Tragödie, das andere Mal als Farce

More information about the lfs-support mailing list