The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-27-2009
Registered User
 

Join Date: Nov 2006
Posts: 5
Unhappy 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' . 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 (permalink)  
Old 11-27-2009
dj - the student
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 667
try:


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

  #3 (permalink)  
Old 11-27-2009
chakrapani's Avatar
Registered User
 

Join Date: Sep 2009
Location: Asia
Posts: 87
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
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
isql output d_swapneel14 Shell Programming and Scripting 6 11-05-2009 07:31 AM
isql output file not created while running it through cron vikram3.r Shell Programming and Scripting 2 11-05-2009 06:19 AM
ksh + isql => output cut at 2 GB bereman Shell Programming and Scripting 1 09-16-2009 08:16 AM
Isql Data format siquadri Shell Programming and Scripting 1 04-22-2009 04:54 PM
formatting a Compact Flash in DOS format dreamsurfer Windows & DOS: Issues & Discussions 1 03-19-2002 11:43 PM



All times are GMT -4. The time now is 02:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0