0

I've a script that gives the output of status of the many process (on or off). How to align the process name and status in perfect columns..

RED=tput setaf 1
GREEN=tput setaf 2
COL=40
...
...
if /opt/rad/beh.sh status | grep "pid"
then
printf "$i" "$GREEN" $COL "[UP]" "$NORMAL"
else
printf $i "$GREEN" $COL "[UP]" "$NORMAL"
fi

here, 'i' represents the process name that is in the machine.. didn't write the full code here. just need the alignment part corrected. Could someone please help me with this ?

NewLands
  • 73
  • 2
  • 10
  • possible duplicate of [How can I format the output of a bash command in neat columns](http://stackoverflow.com/questions/6462894/how-can-i-format-the-output-of-a-bash-command-in-neat-columns) – Bertram Nudelbach Jul 27 '15 at 10:49

1 Answers1

0

Here's what I did and it worked !

if /opt/rad/beh.sh status | grep "pid"
 then
 printf "\t\t%-46s %-s\n" $i "UP"
 else
 printf "\t\t%-46s %-s\n" $i "DOWN"
 fi
NewLands
  • 73
  • 2
  • 10