0

I have a utility (a wrapper around isql) which executes sybase queries and gives output. I want to separate 2 columns with two tabs. The help for the utility reads:

<-s>       : resets the column separator character, which is blank by default

I tried -s\\t which separates all the columns using a tab.

However trying -s\t\t gives weird output like:

1\t\tS1\t\tmaindb\t\t1\t\t1\t\t1\t\t1\t\t50\t\t10\t\t0\t\tNULL\t\tNULL\t\tNULL\t\tNULL\t\t1\t\t

I have also tried -s' '(eight spaces), -s"\t\t", -s/\t/\t(I knew this wouldn't work, but still), -s\2t, -s\t+1, but nothing seems to work.

How can I resolve this?

1 Answer 1

0

If the isql command allows for a string as an argument to its -s option and not just a single character (I can't test this), then you should be able to specify two tabs using

isql -s $'\t\t' ...

in the bash shell. You may also insert two literal tabs by pressing Ctrl+VTab twice, or by using

isql -s "$( printf '\t\t' )" ...

If the option does not allow for more than a single separator character (as hinted at in the manual, where it says "the column separator character" rather than "the column separator string"), then there is not much you can do other than possibly post-process the result of the query.

The following would double up all tabs coming over the standard input stream from isql (using bash to insert a tab with $'\t'; GNU sed understands \t without the $, and in other shells, use Ctrl+VTab or the printf hack mentioned above):

isql -s $'\t' ... | sed $'s/\t/&&/g'
1
  • Yes, it did not allow the separator string. Have to go with post-processing the query results like you said. Commented May 26, 2019 at 11:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.