How to print output in following format?
A..................ok
AA................ok
AAA..............ok
AAAAAA........ok
"ok" one under one
How to print output in following format?
A..................ok
AA................ok
AAA..............ok
AAAAAA........ok
"ok" one under one
I could not find the exact way to do what i wanted as well.... I wanted anything on right justify to line up regardless of whatever is on the right justify. I also liked the look of the linux style rc scripts.
I beleve now the real answer is in the curses program.
I ended up writing my own function called spaces. It takes the word count from $1 and subtracts it from the stty column width. Regardless of terminal width, the right justify will line up.
Well that might be incorrect depending on what you have in $2.
Here is the code:
spaces () {
integer WIDTH=`stty|grep columns|awk '{print $6}'|awk -F";" '{print $1}'`
let TOTAL=$WIDTH-15
FIELD1=`echo $1 |wc -c`
FIELD2=`echo $2 |wc -c`
integer FIELD1_TOTAL=$FIELD1
let SUM=$TOTAL-$FIELD1_TOTAL
TAB=`echo ' '|sed -e :a -e "s/^.\{1,$SUM\}$/ &/;ta"`
echo "$1 $TAB $2"
}
You would call it in a script with:
spaces "something on the left" "something on the right"
spaces "aaaa aaa aaaa" ok
This is what it looks like: I also embed color into variable for "OK" so it shows in green.
OK="\033[1;32mOK"
FAILED="\033[1;31mFAILED"
CHECKING SVM MIRRORS:
d0 [ c1t0d0s0 ] OK
d10 [ c1t0d0s1 ] OK
d30 [ c1t0d0s3 ] OK
d40 [ c1t0d0s4 ] OK
d50 [ c1t0d0s5 ] OK
d60 [ c1t0d0s6 ] OK
PRIMARY MIRROR: c1t0d0 OK
SVM SECONDARY MIRROR: FAILED
Not sure whether I got ur problem correctly....have a look .
echo a|awk '{ for(i=1;i<=10;i++) {var=""; for (j=1;j<=i;j++) {var=var"A"} for(k=j;k<=10;k++){var=var"."; }print var"ok"; } }'
[code]
echo a|awk '{ for(i=1;i<=10;i++) {var=""; for (j=1;j<=i;j++) {var=var"A"} for(k=j;k<=10;k++){var=var"."; }print var"ok"; } }'
[code]
Please tell me the meaning of "echo a" here
The "." not needed I just put it to show that "OK" must be in one column.
And "AAAAA" it's just an example of some string, for example:
Checking something.......... [OK]
Checking something other..[OK]