[ILUG] can anybody explain thise awk script to me Please

Mark Webb mark.webb at Trintech.com
Wed Aug 29 13:47:46 IST 2001


hrishy wrote:
> 
> This is the text file opn which i run the awk script
> 
> awk script is 
> 
> BEGIN { 
> prev_table="." 
> } 
> { 
> curr_table=$1 
> if ( curr_table!=prev_table ) 
> { 
> prev_table=curr_table 
> printf("\nTable %s : %s",$1,$2) 
> } 
> else 
> { 
> printf(",%s",$2) 
> } 
> } 
> 
> i get the output but can u please explain the if loop.

$0 is the whole line in awk.
$1 is column 1, $2 column 2, etc.
You may override the Field separator by setting FS.

-Mark.

P.S. Some tabs in that awk program would be nice...




More information about the ILUG mailing list