bteq <<EOF | awk 'BEGIN { start=0; } { if (start==1) { if (/^$/) { exit; } else { print; } } if (/^---/) { start=1; } }' .logon host/user,password select top 3 tablename from dbc.tables where databasename = 'myDB' and tablekind='T' order by 1 ; .logoff .exit EOF