something like this :
db2 -x "select TABLESPACE_ID,CONTAINER_NAME,\
case CONTAINER_TYPE when 0 then 'PATH' else 'FILE' end case ,\
TOTAL_PAGES \
from table( SNAPSHOT_CONTAINER('',-1)) as ts " | {
while read TSREC
do
set - $TSREC
ID=$1
CN=$2
CT=$3
TP=$4
.....
done
output of query will be stored in $ID - $CN-$CT-$TP and be handled with script statements..