![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem with dd command or maybe AFS problem | Anta | Shell Programming and Scripting | 0 | 08-25-2006 10:10 AM |
| SSH Problem auth problem | budrito | UNIX for Advanced & Expert Users | 1 | 03-17-2004 10:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
A Doozy of a problem for me
I have a report I need to format into a nice looking fixed length for each column of output
The report looks like this 1. First Query Title First Query syntax (select * from tablea) column1a ,column2a ROWDATA....... ROWDATA....... ROWDATA ...... 2. Second Query Title Second Query syntax (select * from tableb) column1b ,column2b ROWDATA ......................................................,ROWDATA ROWDATA.......................................................,ROWDATA 3. Third Query Syntax Second Query syntax (select * from tablec) column1c ,column2c ROWDATA.................................,ROWDATA ROWDATA.................................,ROWDATA As you can see the column width varies from each query result set. how can I format this report to find the end of each column yes they are all separated by commas and add only one space in order to compact the report. The dots in each row represents a space This one is really tough for me any help is greatly appreciated. Thanks |
|
||||
|
I'm not a great sql person so I normally make a file of the data from the sql statements and then use awk (as sugegsted before) to format how I want it.
I normally put it in a script, a bit like this. sqlplus -s user/password > a_temp_file <<! set lin 500 set pages 0 select '~', statement.... .... ..; ! I use the ~ so I can search on it later. Then with in the same script you can use awk on the a_temp_file to change the format to what you desire. Awk should remove the extra empty spaces. awk '/~/ {print $1, $2, $3, $4}' a_temp_file > report_file. You can change the , to <tab> "\t" or any thing else. You can also easily put coloumn names and things like that. Hope it helps |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|