change the output format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting change the output format
# 1  
Old 05-07-2010
change the output format

when i run the following command

Code:
db2 list tablespaces 

            Tablespaces for Current Database

 Tablespace ID                        = 0
 Name                                 = SYSCATSPACE
 State                                = 0x0000
   
 Tablespace ID                        = 1
 Name                                 = TEMPSPACE1
 State                                = 0x0000

i want it to display the output as

Code:
Tablespace ID    Name                       State
            0        SYSCATSPACE            0x0000
            1        TEMPSPACE1              0x0000

can someone guide how to use awk for this in a single command or some other process .

Last edited by zaxxon; 05-07-2010 at 09:29 AM.. Reason: use code tags please, ty
# 2  
Old 05-07-2010
As a starting point, you can try something like that :
Code:
db2 list tablespaces | \
awk -F '[[:space:]]*=[[:space:]]* ' '
BEGIN            { print "Tablespace_ID Name State"; }
/^Tablespace ID/ { id    = $2 ; next }
/^Name/          { name  = $2 ; next }
/^State/         { print id, name, $2 }
'

Jean-Pierre.

Last edited by aigles; 05-07-2010 at 09:46 AM..
# 3  
Old 05-07-2010
Code:
SELECT DBNAME, NAME FROM SYSIBM.SYSTABLESPACE ORDER BY DBNAME,NAME

or 

SELECT TBSPACE FROM SYSIBM.SYSTABLES WHERE NAME = 'table_name' AND CREATOR='schema_name';

# 4  
Old 05-07-2010
State of a table space cannot be predicted by using the systablespaces tables.Therefore i am going for the script .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

2. Shell Programming and Scripting

Change name format

I am trying to use either awk or sed to make names like J. A. Smith and J.A. Martin Smith become JA Smith and JA Martin SmithThe code should concatenate abbreviated letters that have a dot after them. I have only been able to do this: echo $name | sed 's/\.\ //g'But that concatenates the... (3 Replies)
Discussion started by: locoroco
3 Replies

3. Shell Programming and Scripting

Format change

I wish to convert the following in shell. Help me SED or AWK ID= 12345,23456,67859 , 90225 , 67583 I can extract the right hand side of "=" using cut command "cut -d "=" -f2 after extracting that right side i would need like this '12345','23456','67859','90225','67583' 1 ) the... (2 Replies)
Discussion started by: ilugopal
2 Replies

4. AIX

How change format of storage

First padd the string with spaces and then store in file (e.g result) with"" Example: i/p: name="abc" echo "$name">>result Blank space..=12 Required o/p of Result file: "abc " # "Value 12 blank space" How to perform using scripting??:confused: Please use code tags,... (1 Reply)
Discussion started by: AhmedLakadkutta
1 Replies

5. Shell Programming and Scripting

change output format using ksh

I have a script that reaches out to several systems and pulls back infomation in serveral files. I would like to take the infomation returned and reformat it so I can export it to excel. Below is current output: File1:item1:abc=1 File1:item2:efg File2:item1:ab=1 File2:item2:efg... (3 Replies)
Discussion started by: oldman2
3 Replies

6. Shell Programming and Scripting

format change

I have a text file sample.txt which contains some details like Order 9001 Item Code 34 Quantity 4 Entry Date 2009-04-23 Ordered by Ram Order 9002 Item Code 34 Quantity 3 (1 Reply)
Discussion started by: lazydev
1 Replies

7. Shell Programming and Scripting

How can I change is output format by awk ?

Hello, Can you tell me how can I change this format by awk Input 0.2057422D-01 0.2463722D-01 -0.1068047D-02 Output 0.02057422 0.02463722 -0.001068047 Thanks wan (8 Replies)
Discussion started by: wanchem
8 Replies

8. Shell Programming and Scripting

Change file output format

I have a file which has following contents usmtnz-dinfsi19 62 61 18400 18800 99.7 usmtnz-dinfsi19 62 61 18400 18800 99.7 i want the o/p to be like date (7 Replies)
Discussion started by: fugitive
7 Replies

9. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

10. Shell Programming and Scripting

change the empty function from the old format to the new format

I have about 300 files which has the function getDBBackend(). How to write a program to change the empty function from the old format to the new format? Old empty function format are either: function getDBBackend() { // Not available } // getDBBackend or: function... (0 Replies)
Discussion started by: powah
0 Replies
Login or Register to Ask a Question