1) way1 ps xH -o 'pid tid cmd comm pcpu psr' 2) way2 #!/bin/bash TMP_FILE=$(mktemp /tmp/abc-script.XXXXXX) echo ${TMP_FILE} ps xH -o 'pid tid cmd comm pcpu ' > ${TMP_FILE} function make_header() { echo -n "$1" echo " psr" } function make_values() { echo -n "$1" STATUS_FILE=/proc/${2}/task/${3}/status if [ -f ${STATUS_FILE} ] ; then CPU_SET=`cat ${STATUS_FILE} |grep Cpus_allowed_list |awk ' { print $2 } '` else CPU_SET="None" fi echo " ${CPU_SET}" } let IDX=0 while IFS='' read -r line || [[ -n "$line" ]]; do LINE_SEP=( $line ) MY_PID=${LINE_SEP[0]} MY_TID=${LINE_SEP[1]} if [ ${IDX} -eq 0 ]; then SZ_HEADER=`make_header "$line"` echo ${SZ_HEADER} else SZ_VALUES=`make_values "$line" ${MY_PID} ${MY_TID}` echo ${SZ_VALUES}...