Need Help 
Author Message
 Need Help

Hello Everybody,

I am working on one awk script. I need help in that. Following is the
requirement

I need to display a kind of spread sheet of following details.

DBSLICE1          DBSPACE.1       CHUNK.1    SIZE(KB)
                  DBSPCAE.2       CHUNK.2    SIZE(KB)
DBSLICE2          DBSPACE2.1      CHUNK2.1   SIZE(KB)

I am taking input from $INFORMIXDIR/etc/xcfg_$INFORMIXSERVER.SERVERNUM
- The file detail looks like

DBSlice 1 6 1 32768 rootdbs
DBSlice 2 72 7 8193 tmpslc
DBSlice 3 24 649 1 kd_slc
DBSpace 1 1 1 98304 1 1 1 1 6 rootdbs.1
DBSpace 2 2 1 98304 6 6 1 6 -1 rootdbs.6
DBSpace 3 3 1 98304 5 5 1 5 2 rootdbs.5
Chunk 1 1 -1 524284 4 13 /ix/rootdbs.1 0 0
Chunk 2 2 -1 524284 4 13 /ix/rootdbs.6 0 0
Chunk 3 3 -1 524284 4 13 /ix/rootdbs.5 0 0

Required output should be

rootdbs          rootdbs.1      /ix/rootdbs.1  524284
                 rootdbs.6      /ix/rootdbs.6  524284

so on for all the dbslices.
I made the following script

#!/bin/ksh
FILE=xcfg_sdwp1m.1
(
        ## Display a header
        printf "%-35s\t%-35s\t%-35s\t%11s\n" "DBSlice" "DBSpace"
"Chunk" "Size"
        printf
"----------------------------------------------------------------------------------------------------------------------------------

-\n"

cat xcfg_sdwp1m.1|awk '{
if ($1 == "DBSlice") print $4, $6 > "/tmp/sdwprod_dbslices.out"
if ($1 == "DBSpace") print $2, $8, $11 > "/tmp/sdwprod_dbspaces.out"
if ($1 == "Chunk") print $3, $8, $5 > "/tmp/sdwprod_chunks.out"

Quote:
}'

cat /tmp/sdwprod_dbslices.out|sort +0 > "/tmp/dbslices_sort.out"
cat /tmp/sdwprod_dbspaces.out|sort +1 > "/tmp/dbspaces_sort.out"
cat /tmp/sdwprod_chunks.out|sort +0 > "/tmp/chunks_sort.out"
echo ' '|nawk 'BEGIN{
                        ## Load the input in the array
                        while (( getline < "/tmp/dbslices_sort.out" )
Quote:
>0)

                        {
                        dbslice++
                        sdwprod_dbslices[dbslice]=$0
                        }
                        while (( getline < "/tmp/dbspaces_sort.out" )
Quote:
>0)

                        {
                        dbspace++
                        sdwprod_dbspaces[dbspace]=$0
                        }
                        while (( getline < "/tmp/chunks_sort.out" ) >0)
                        {
                        chunk++
                        sdwprod_chunks[chunk]=$0
                        }
                }
{
        for (dbslice in sdwprod_dbslices)
        {
        if (sdwprod_dbslices[$1] == sdwprod_dbspaces[$2] &&
sdwprod_dbspaces[$1] == sdwprod_chunks[$1])
                {
                        sdwprod_final[1] = sdwprod_dbslices[2]
                        sdwprod_final[2] = sdwprod_dbspaces[3]
                        sdwprod_final[3] = sdwprod_chunks[2]
                        sdwprod_final[4] = sdwprod_chunks[3]

                }
        }

Quote:
}

END {
        for (i in sdwprod_final)
        {
                printf ("%-35s\t%-35s\t%-35s\t%11d\n",
                        sdwprod_final[1],
                        sdwprod_final[2],
                        sdwprod_final[3],
                        sdwprod_final[4]*4)
        }
Quote:
}' $FILE

) | more

This script is not giving the required output. I will highly appreciate
if someone can suggest the required change or some other way in awk to
do this.

Thanks

Sanjeev K. Sagar



Sun, 28 Oct 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Need help launching external non rexx command using VXREXX (VIO support needed) in OS/2

2. Java in VRML code...need help...or need a piano/keyborad.wrl

3. Need help to grok c extension that needs to use callbacks with data

4. HELP - I need help

5. HELP!! Need help with browse window

6. Help Files, Need Help

7. help i need help

8. HELP! NON-PROGRAMMER NEEDS HELP

9. HELP: Need help with Ms-Dos batch lang..

10. I need help........programming help!

11. Need Help How Can Help me

12. Need Help How can Help ?

 

 
Powered by phpBB® Forum Software