Solved

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

Posted on 2010-11-23
4
4,634 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

710 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