If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Sorting on a Line Item

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-26-07, 10:09
atl_geek atl_geek is offline
Registered User
 
Join Date: Jul 2007
Posts: 14
Sorting on a Line Item

I Have a file that contain the following paragraphs. How to sort these paragraphs on "Rows Read" or "Rows Written" or "Overflows"

Table Schema = SYSIBM
Table Name = SYSTABLES
Table Type = Catalog
Data Object Pages = 55
Index Object Pages = 27
LOB Object pages = 1728
Rows Read = 2121
Rows Written = 1
Overflows = 5
Page Reorgs = 0

Table Schema = SYSIBM
Table Name = SYSCOLUMNS
Table Type = Catalog
Data Object Pages = 459
Index Object Pages = 241
Rows Read = 1039
Rows Written = 4
Overflows = 45
Page Reorgs = 1

Table Schema = SYSIBM
Table Name = SYSCOLUMNS
Table Type = Catalog
Data Object Pages = 55
Index Object Pages = 27
LOB Object pages = 1728
Rows Read = 2121
Rows Written = 1
Overflows = 5
Page Reorgs = 0

Table Schema = SYSIBM
Table Name = SYSPROCS
Table Type = Catalog
Data Object Pages = 459
Index Object Pages = 241
Rows Read = 1039
Rows Written = 4
Overflows = 45
Page Reorgs = 1


Thx ahead for the help
Tony
Reply With Quote
  #2 (permalink)  
Old 07-26-07, 10:54
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Try and adapt the following script :

Code:
awk -v Field='Overflows' '
   BEGIN {
      RS  = "";
      FS  = "\n" 
      Field = toupper(Field) 
      Field_pattern = ".*" Field " = ";
   }
   { 
      Value = toupper($0);
      sub(Field_pattern, "", Value);
      sub(/\n.*/, "", Value);

      for (i=1; i<=NF+1; i++) {
         print Value,NR,i,$i
      }
   }
' input_file |
sort -k1,3n |
cut -f4-
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On