Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isql & -s switch 1

Status
Not open for further replies.

autopdf

Programmer
Mar 6, 2003
2
US
hi,

i am trying to generate a tab-separated report using the isql utility. However when I use the -s switch, the output generated has a tab even at the beginning of the column. This is a problem. How do you eliminate the tab (or any othere specified delimiter) from appearing at the beginning of the 1st column.

thanxs!
 
hello,

not exactly sure if you can eliminate it just by using isql...

i eliminate it using sed or perl...

set nocount on in your sql...
and use the -b option (compliments of dickiebird) in your isql to remove the header and the count... so you just get the data and the separators...

here's the perl script i use...
----
#! /usr/bin/perl

$inFile = $ARGV[0];
$outFile = $ARGV[1];

open IN_FILE,"$inFile" or die "Can not open $inFile!";
open OUT_FILE,"$outFile" or die "Can not open $outFile!";

while ($row = <IN_FILE>)
{
$row =~ s/^\s+//g;
$row =~ s/\s+$//g;

print OUT_FILE &quot;$row\n&quot;;
}

close OUT_FILE;
close IN_FILE;
----

if you want to get medieval... you can use vi and execute the following:

vi the file
type :%s/^ //g <ENTER>
type :%s/ $//g <ENTER>
type :wq! <ENTER>

hth,
q.
 
Thanks for the credit, qyllr
here's another way to use vi in a script, without actually going into the vi editor itself
(This removes a tab at the start and/or end of any line):
#!/bin/ksh
vi yourfile << EOF
:%s/^ //g
:%s/ $//g
:wq
EOF

The two spaces above are tabs, of course
HTH
Dickie Bird (:)-)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top