Solved

sybase isql - output file contains leading and trailing spaces per each column

Posted on 2010-11-23
4
4,369 Views
Last Modified: 2012-05-10
I am using sybase Adaptive Server Enterprise/15.0.2 and running isql from UNIX (solaris 10) to get data from sybase to use other application.
isql -S <server> -U <ID> -P <password> -i <sql file> -s"|" > $outfile

currently result file always contains too many space per column, and I do not want this happen.
would you advise how I can get rid of these spaces ? I've checked manual for isql but could not find such a option...
0
Comment
Question by:sleepingluke
  • 3
4 Comments
 
LVL 26

Expert Comment

by:wilcoxon
ID: 34202772
You can't get rid of it with isql itself.  I would suggest running it through sed (this will remove leading and trailing spaces per line):

isql -S <server> -U <ID> -P <password> -i <sql file> -s "|" | sed -e 's%^  *%%' -e 's%  *$%%' > $outfile

If you mean the columns themselves have too many spaces, in the output display, then I'm not sure what to suggest as the output from isql will always make columns the widest necessary (usually the width defined in the source table).  You could try using subtring or convert in your sql if you know that the max width will be less than the max defined for the column.
0
 
LVL 26

Expert Comment

by:wilcoxon
ID: 34202777
It may not help in this situation (I can't remember all the options off-hand) but I would suggest installing sqsh for use instead of isql.  sqsh is what isql should have been.
0
 
LVL 26

Accepted Solution

by:
wilcoxon earned 500 total points
ID: 34202786
Hmm, actually, given the output format of -s "|", this command should work for getting rid of extra spaces per column:

isql -S <server> -U <ID> -P <password> -i <sql file> -s "|" | sed -e 's%|  *%%' -e 's%  *|%%' > $outfile

You may need to add a backslash before the |s in the sed expressions (I always forget if you need them or not to work properly).
0
 

Author Closing Comment

by:sleepingluke
ID: 34202992
thanks! actually below command worked though I just replaced % to / and all rely to your command, appreciated.

isql -S <server> -U <ID> -P <password> -i <sql file> -s "|" | sed -e 's/|  */|/g' -e 's/  *|/|/g' > $outfile
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question