I am having a problem where the Compute field/column is spilling over to the new line. Here's the piece of code and the o/p:-
Code Sniplet:-
for id in `qstat -u "*" -q "$Queue" -s r |sed -n '3,$ p'|awk -F" " '{print $1}'`
do
NODELIST=`cat /scratch/$id.hostlist.*|awk -F" " '{print $1,$2}'|tr ' ' '*'|sed ':a;N;$!ba;s/\n/,/g'`
NODES=`cat /scratch/$id.hostlist.*|awk -F" " '{print $1}'|wc -l`
echo -ne "$id $NODES $NODELIST\n" >> "$TMPFILE2"
done
cat "$TMPFILE2"|awk -F" " 'BEGIN { printf "%-15s %-15s %s\n","JOBID","NDS","COMPUTE"
printf "%-15s %-15s %s\n","-----","-----","-----"}
{ printf "%-15s %-15s %s\n",$1,$2,$3 }'
output:-
JOBID NDS COMPUTE
----- ----- -----
4884 32 n264*1,n246*1,n263*1,n270*1,n269*1,n249*1,n258*1,n242*1,n271*1,n383*1,n151*1,n156*1,n160*1,n161*1,n1 62*1,163*1,n164*1,n165*1,n166*1,n167*1,n168*1,n173*1,n385*1,n377*1,n183*1,n184*1,n185*1,n189*1,n192* 1,n194*1,n195*1,n196*1
5034 2 n305*4,n308*4
Expected o/p :- Want to align Compute node data which are spilling onto new line and are beginning from start
output:-
JOBID NDS COMPUTE
----- ----- -----
4884 32 n264*1,n246*1,n263*1,n270*1,n269*1,n249*1,n258*1,n242*1,n271*1,n383*1,n151*1,n156*1,n160*1,n161*1,n1
62*1,163*1,n164*1,n165*1,n166*1,n167*1,n168*1,n173*1,n385*1,n377*1,n183*1,n184*1,n185*1,n189*1,n192* 1,n194*1,n195*1,n196*1