Formatting isql output to horizontal format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting isql output to horizontal format
# 1  
Old 11-27-2009
Data Formatting isql output to horizontal format

Hi

I am formatting informix isql output(vertical) to horizontal format. Suppose I have the following content in the flat file from isql output -

item_nbr 0
usfn_label Subscriber Class
usfn_name SBCLASS
usfn_value bl5

item_nbr 1
usfn_label Switch Name
usfn_name switchName
usfn_value pyrw2

I have to format it like -

item_nbr usfn_label usfn_name usfn_value

0 Subscriber Class SBCLASS bl5
1 Switch Name switchName pyrw2

I printed the column headers in the output file and then I want to get the column values. I used 'cut' to get the values like this in a file tmp-

0
Subscriber Class
SBCLASS
bl5

1
Switch Name
switchName
pyrw2

Now the problem is whenever I am trying to print the values in the output file, they are appearing with newline (\n) and I am not getting the horizontal format. As if there is a newline after '0', 'Subscriber Class' etc and the print command is also printing the newline -

while read line
do
if [ -n "$line" ];then
print "$line\t" >> out
else
print "\n" >> out
fi
done<tmp

But 'out' has the same format like 'tmp' Smilie . I have tried several values for IFS without any success.

So how we can read vertically and print them horizontally ????


Please show me the light ....

Thanks
# 2  
Old 11-27-2009
try:

Code:
cut -f2- -d" " file | xargs -n5

# 3  
Old 11-27-2009
Is it possible to change isql command .. Which will better that a shell script ..

Check with
SyBooks Online

-w columnwidth
Default= 80 characters
meaning = Changes the line width
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python Output Displaying Horizontal

I feel bad for posting so much lately. I've just been working on a project for fun to force myself to learn Python better. Recently I decided to incorporate this ping.py script on github found here. I'm not going to bore you with all the changes I made, but the problem now lies in this function... (8 Replies)
Discussion started by: Azrael
8 Replies

2. Shell Programming and Scripting

Help! output format from vertical to horizontal

Hi All, please help to achieve the desired output Example: I have a file which contains the below data empname robert empid 787 design consultant empname alex empid 898 design advocate Desired output should be empname empid design robert 787 consultant (19 Replies)
Discussion started by: rocky2013
19 Replies

3. Shell Programming and Scripting

Output with horizontal formats

// AIX 5.3 & 6.1 This command powermt display dev=all returns the output of Pseudo name=hdiskpower50 Symmetrix ID=000190101757 Logical device ID=05F0 state=alive; policy=SymmOpt; priority=0; queued-IOs=0 ==============================================================================... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

4. Shell Programming and Scripting

Need perl or shell script to sort vertical lines to horizontal line in csv format

Need perl or shell script to sort vertical lines to horizontal line in csv format My file like below ------------------------- ================================================================================ PATH PINKY1000#I1-1-ZENTA1000-2#I7-1-ASON-SBR-UP-943113845 ... (4 Replies)
Discussion started by: sreedhargouda.h
4 Replies

5. Shell Programming and Scripting

Request for horizontal formatting code

The input file contains 4 bytes per row 1 2 3 4 5 6 7 8 9 10 11 12 * * * 108 1 2 3 4 5 6 7 8 9 10 11 12 * * * 108 I need to put them in a horizontal manner and this need to repeat after every 108 lines lso the output comes as 1 2 3 4 5 6 7 8 9 10 11 12 ..... 108 1 2... (4 Replies)
Discussion started by: necro98
4 Replies

6. Shell Programming and Scripting

formatting into CSV format of SQL session output

I am getting a no of fields from a SQL session (e.g. select a,b,c from table). How do I convert the output values into CSV format . The output should be like this 'a','b','c', (4 Replies)
Discussion started by: mady135
4 Replies

7. Shell Programming and Scripting

CSV file horizontal formatting

Hi folks, Please help me with csv file formatting which needs to be done in horizontal fashion. I have data coming in separate files every hour. What I need to do is extract three values into csv file. In the next hour, I need to extract the new values beside the three values which were... (1 Reply)
Discussion started by: vharsha
1 Replies

8. Shell Programming and Scripting

isql output

hi all i m running following code # set up environment . /u/pimms/pimms_global.ksh echo "Get record from database" #echo ${PIMMS_ID} #echo ${PIMMS_PWD} #echo "1" isql -U${PIMMD_ID} -P${PIMMS_PWD} -S$SRV << eof > /sybase/applications/pimms/bin/automate1.txt use pimms ... (6 Replies)
Discussion started by: d_swapneel14
6 Replies

9. Shell Programming and Scripting

ksh + isql => output cut at 2 GB

Using a ksh script, I'm dumping the data from our sybase database into an output file. This output file is for what ever reason cut at 2GB. There is enough space on the unix machine and as there is no error message is received I have no clue to start looking for a solution. #!... (1 Reply)
Discussion started by: bereman
1 Replies

10. Shell Programming and Scripting

Isql Data format

I am using the following script #!/bin/ksh /usr/sybase/bin/isql -SXYZ -UABC -PXYZ -b <<EOF >temp select A.host,A.server,B.db,A.status from dbo.server as A,dbo.db as B where A.product in (XX,YY) and A.server=B.server go EOF Result: Results: host1 server1 ... (1 Reply)
Discussion started by: siquadri
1 Replies
Login or Register to Ask a Question