Trace top 5 thread on Solaris with truss tool

# prepare a list of top 5 CPU demanding thread
eval `prstat -L -n 5 1 1|sed '1d;$d'|/usr/bin/awk '{p[$1]=p[$1]+1;split($NF,i,"/");if(a){l=l sprintf "|%s/%s:",$1,i[2]}else{a=1;l=l sprintf "%s/%s:",$1,i[2]}}END{printf "export PIDS=\"";for(j in p){printf "%s ",j};printf "\"\nexport FIL=\"";printf "%s\"\n",l}'`; echo $PIDS; echo $FIL
# start truss with filtering
truss -aefld -rall -wall -p $PIDS 2>&1 | egrep "$FIL"