Sponsored Content
Top Forums Shell Programming and Scripting manipulate & format the output of spool command Post 302335106 by ss_ss on Friday 17th of July 2009 08:50:29 AM
Old 07-17-2009
manipulate & format the output of spool command

Hi All,

I am spooling the data some sql queries into a single file but wanted to know how to format the data of the file generated by spool.

Code:
#!/bin/sh
unset -f USAGE
USAGE () {
clear
echo "############################USAGE#######################\n"
echo "Incorrect number of parameters\n"
echo "Usage: ${1} <DBUser>"
echo "Usage: ${2} <DBPassword>"
echo "########################################################\n"
exit -1;
}
 
if [ $# -ne 2 ]; then
USAGE
fi
 
username=$1
password=$2
 
sqlplus -s $username/$password@DB_TGT01 << END
SET SERVEROUTPUT OFF
SET VERIFY OFF
SET FEEDBACK OFF
SET ECHO OFF
set LINESIZE 5000
set TRIMSPOOL on
spool reco-counts-SRC_TGT.txt
 
select TABLE_NAME "Table_Name", ROWCOUNTS "Source_CU01" from DBS_Table_counts@DB_SRC order by TABLE_NAME;
 
select ROWCOUNTS "Target_CU01" from DBS_Table_counts order by TABLE_NAME;
 
select ROWCOUNTS "Target_CU04" from DBS_Table_counts@DB_TGT04 order by TABLE_NAME;
 
select ROWCOUNTS "Target_CU06" from DBS_Table_counts@_TGT06 order by TABLE_NAME;
 
select ROWCOUNTS "Target_CU07" from DBS_Table_counts@_TGT07 order by TABLE_NAME;
spool off;
exit;
END

Now the expected output what i want is

Code:
Col1   Col2   Col3   Col4   Col5   Col6   Col7   Col8
A       4       1       1       1       1       4       0
B       26      5       8       4      9       26      0
C       70      1      10      55     0       67      -3
 
where Col1 is Table_Name from 1st query
Col2 is Source_CU01 from 1st query
Col3 is Target_CU01 from 2nd query
Col4 is Target_CU04 from 3rd query
Col5 is Target_CU06 from 4th query
Col6 is Target_CU07 from 5th query
Col7 is values of (Col3+Col4+Col5+Col6)
Col8 is values of Col7 - Col2

Is this kind of formatting & manipulation is possible?

Thanks
 

10 More Discussions You Might Find Interesting

1. Solaris

Making sense of df -k & format verify output

I'm posting the output from two disks on my Solaris machine. The first part is the output from using the format command and then using the verify option on each disk. The last part is the output from my df -k command. I'm trying to match the partition to the filesystem/mount point. I'm assuming... (13 Replies)
Discussion started by: gonzotonka
13 Replies

2. Shell Programming and Scripting

manipulate data with specific format

Hi everybody: I have a problem with how I have to manipulate the data which have specific format like this: 249. 0.30727021E+05 0.30601627E+05 0.37470780E-01 -0.44745335E+02 0.82674536E+03 248. 0.30428182E+05 0.30302787E+05 0.40564921E-01 -0.45210293E+02 ... (5 Replies)
Discussion started by: tonet
5 Replies

3. Shell Programming and Scripting

Format Output with AWK command

Hi - I have a file with contents as below. 12.1 a.txt 12.1 b.txt 12.1 c.txt 13.2 a.txt 13.2 d.txt 14.3 f.txt 15.4 a.txt 15.4 b.txt 15.4 z.txt I need to print the contents like this. 12.1 a.txt <&nbsp><&nbsp><&nbsp>b.txt <&nbsp><&nbsp><&nbsp>c.txt (7 Replies)
Discussion started by: guruparan18
7 Replies

4. UNIX for Dummies Questions & Answers

crontab & var/spool/mai

Hi there, I'm using crontab to move some files every minute, but when crontab doesn't find these files it sends a message to the file "user_name" in the directory "var/spool/mail". Is it possible to "bypass" this problem? Thanks in advance, Giordano Bruno (1 Reply)
Discussion started by: Giordano Bruno
1 Replies

5. Shell Programming and Scripting

Help me to command to output file format.

Dear Master. Help me to command to out put. Ex log. "<?xml version=""1.0"" encoding=""UTF-10"" ?><anova-test-bom> <txid>17251032659</txid> <authentication> <user>admin</user> <password>Amrduoi</password> </authentication> <destination> <msisdn>1111111</msisdn> ... (2 Replies)
Discussion started by: ooilinlove
2 Replies

6. AIX

How to manipulate date format?

Hi, I need to convert the below string in 'yyyymmdd' format. e.g., 24 June 2011 -> 20110624 Please help !! (4 Replies)
Discussion started by: ruby
4 Replies

7. Shell Programming and Scripting

incrementing lines in the file & format output.

Hi All, I need read the file and out put format as below using ksh, I wrote below script its keep on repeating first line in the file. may i know the best way to get the below out put while incrementing line in the file. cat b.txt |awk '{print $0}' |while read line do aa=`cat $line |head -1... (7 Replies)
Discussion started by: ashanabey
7 Replies

8. Shell Programming and Scripting

Format output from command from variables

Hi , I have below command to that outputs from variables.. command: echo $INSTANCE $DATAB $status $TSLastBackup| awk '{printf("%-8s %-8s \t \n",$1,$2,$3,$4)}' | tee $LOGF the ouput is now: INSTANCE DATABSE BACKUP_STATUS BACKUPTIMESTAMP ------- -------- -------- ... (1 Reply)
Discussion started by: db2_usd
1 Replies

9. Shell Programming and Scripting

How to format output of command?

Hi how do you change the format of the output of ls -lt -c -R $HOME | sed /^total/d From: /home/pikamon/Desktop: -rwxr-xr-x 1 pikamon pikamon 35 Sep 18 14:25 fileModified.sh -rwxr-xr-x 1 pikamon pikamon 87 Sep 18 14:25 fileModified.sh~ /home/darksky21/Downloads: -rwxrw-rw- 1 pikamon... (5 Replies)
Discussion started by: pikamon
5 Replies

10. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies
FAXABORT(8C)															      FAXABORT(8C)

NAME
faxabort - tell a HylaFAX server to abort a receive SYNOPSIS
/usr/sbin/faxabort [ -q dir ] modem DESCRIPTION
faxabort sends a message to a HylaFAX faxgetty(8C) process servicing modem telling it to abort any active receive operation. The specified modem can either be the name (typically the last component of the terminal port the modem is attached to), or the full name of the associated FIFO named pipe file, e.g. ``FIFO.ttym2''. Note that to abort a send operation the faxrm(1) command must be used. OPTIONS
-q dir Use a spooling area other than /var/spool/fax. NOTES
On some systems it is not possible to abort a received facsimile because of problems in the operating system; on such systems the message sent by faxabort will be (silently) ignored. FILES
/var/spool/fax default spooling area /var/spool/fax/FIFO fifo for contacting faxq Consult hylafax-server(5F) for a complete discussion of the structure and content of the spooling area. SEE ALSO
hylafax-server(5F), faxq(8C), faxgetty(8C) March 3, 1995 FAXABORT(8C)
All times are GMT -4. The time now is 06:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy