From: Dave Neary (dave.neary at domain palamon.ie)
Date: Wed 29 Aug 2001 - 09:55:21 IST
hrishy wrote:
>
> Hello
>
> This is the text file opn which i run the awk script
>
> cust_tab custid number
> cust_tab custname varchar2(20)
> cust_tab custaddr varchar2(40)
> cust_tab custphone varchar2(16)
> cust_tab updateuser varchar2(16)
> lang_tab langid number
> lang_tab langnam varchar2(30)
> lang_tab langdesc varchar2(30)
> lang_tab updateuser varchar2(16)
>
> awk script is
>
> BEGIN {
> prev_table="."
> }
Before any lines are processed, set the variable prev_table to a value
which won't occur ever in the file.
> {
This code will apply to all lines...
> curr_table=$1
Set the current table to the first word on the current line
> if ( curr_table!=prev_table )
If the current table isn't the same as the previous table,
> {
> prev_table=curr_table
> printf("\nTable %s : %s",$1,$2)
Print the name of the table, with the second word after a colon & set
the pre_table value to the current table (for future checks).
> }
> else
> {
> printf(",%s",$2)
Otherwise (if the previous table and the current table have the same
name), just print the second word with a , before it.
> }
> }
So the input file should generate
Table cust_tab: custid, custname, custaddr, custphone, updateuser
Table lang_tab: langid, langnam, langdesc, updateuser
Cheers,
Dave.
-- David Neary, E-Mail dave.neary at domain palamon.ie Palamon Technologies Ltd. Phone +353-1-634-5059
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:11:52 GMT