Link to home
Start Free TrialLog in
Avatar of Francisco
FranciscoFlag for Japan

asked on

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

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...
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

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.
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.
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Francisco

ASKER

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