True. You are starting a regular db2 clp, and that comes with all the things that are written to standard output. What you can do is to get rid of the CLP output itself:
Code:
db2 -tz output &>/dev/null <<EOF
connect to db;
select * from syscat.tables fetch first 10 rows only;
EOF
However, you will still see the output from the CONNECT operation, data and DB2 messages in the "output" file. You could add the option -x to suppress column headers or -a to add SQLCA output (or whichever other options you can use).
Separating the different output messages is a different story. First, how would you want to separate them? Write things to different files? Or use different output streams? If the latter, which streams do you have in mind? I believe you have only two options:
(1) Parse the output yourself (using Perl or whichever programming language you prefer for such a task, or
(2) Do not use the DB2 CLP but implement a small application of your own.