Help!!! crazy unix , awk scripting program

Help!!! crazy unix , awk scripting program

am 03.10.2007 05:26:31 von rdprasad.ravi

consider a file with the following format: a header row with

colon-separated field names, and data rows with colon-separated
values. for

example:



AGE:EYES:HAIR

32:BLUE:BLONDE

54:BROWN:BROWN



write a script, named extract_columns, that prints out the values

corresponding to the fields specified by the user on the command line,
in
the

order specified by the user. suppose that the above file was named
data.txt
..

then typing:



%> extract_columns data.txt EYES



should produce



BLUE

BROWN



and typing:



%> extract_columns data.txt HAIR AGE



should produce



BLONDE 32

BROWN 54



the script should die with a warning if the user requests a field that
does

not exist in the data file. The script should run on any input file
that

conforms to the format described above.

Re: Help!!! crazy unix , awk scripting program

am 03.10.2007 05:57:39 von Ed Morton

rdprasad.ravi@gmail.com wrote:

> consider a file with the following format: a header row with
>
> colon-separated field names, and data rows with colon-separated
> values. for
>
> example:
>
>
>
> AGE:EYES:HAIR
>
> 32:BLUE:BLONDE
>
> 54:BROWN:BROWN
>
>
>
> write a script, named extract_columns, that prints out the values
>
> corresponding to the fields specified by the user on the command line,
> in
> the
>
> order specified by the user. suppose that the above file was named
> data.txt
> .
>
> then typing:
>
>
>
> %> extract_columns data.txt EYES
>
>
>
> should produce
>
>
>
> BLUE
>
> BROWN
>
>
>
> and typing:
>
>
>
> %> extract_columns data.txt HAIR AGE
>
>
>
> should produce
>
>
>
> BLONDE 32
>
> BROWN 54
>
>
>
> the script should die with a warning if the user requests a field that
> does
>
> not exist in the data file. The script should run on any input file
> that
>
> conforms to the format described above.
>

don't multi-post. answered in comp.lang.awk.

Re: Help!!! crazy unix , awk scripting program

am 03.10.2007 07:23:27 von gazelle

In article ,
Ed Morton wrote:
....
>don't multi-post. answered in comp.lang.awk.

I wouldn't exactly say "answered".

But I would like to say "What is homework, Alex?"