0

There is probably a very simple solution here, but I am probably not using the right search terms. I have a sql query running in a shell script. I get the results I am looking for, however, I am also getting the sql query as part of of the result. How can I suppress this and just show the result?

My script:

#!/usr/bin/sh

db2 connect to MYDB >/dev/null 2>&1;
db2 -x -v "select A, B, C from MYTABLE";
db2 connect reset >/dev/null 2>&1;

And my output looks like this:

select A, B, C from MYTABLE
AAA   BBB   CCC
AAA   BBB   CCC

I would like to get rid of the first row and just show the result. What am I missing?

Thanks in advance for your help!

1
  • do you just want to get rid of the first row ? Commented Dec 7, 2012 at 22:35

3 Answers 3

3

The -v option for the DB2 command line processor causes the current statement being executed to be printed in the output.

Remove the -v from your command and you'll get only the results of the query.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! This goes in the category of one of my dumbest questions, but had to ask;)
3

if you just want to skip the 1st row from your output you could:

yourscript.sh | tail -n +2

test with seq:

kent$  seq 5|tail -n +2  
2
3
4
5

Comments

0

Try this

db2 -o query

for more info. http://www.ibm.com/developerworks/data/library/techarticle/adamache/0109adamache.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.