I am writing a bash shell script to display if a process is running or not.
So far, I got this:
printf \"%-50s %s\\n\" $PROC_NAME [UP]
Pure Bash. Use the length of the value of 'PROC_NAME' as offset for the fixed string 'line':
line='----------------------------------------'
PROC_NAME='abc'
printf "%s %s [UP]\n" $PROC_NAME "${line:${#PROC_NAME}}"
PROC_NAME='abcdef'
printf "%s %s [UP]\n" $PROC_NAME "${line:${#PROC_NAME}}"
This gives
abc ------------------------------------- [UP]
abcdef ---------------------------------- [UP]