Solved

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

Posted on 2010-11-23
4
4,210 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now