0

I would like to print data format like this in bash shell. Can you suggest how to print the numbers out?

Number=     1
Number=    10
Number=   100
Number=  1000
Binh Thien
  • 363
  • 2
  • 13
  • Does this answer your question? [right align/pad numbers in bash](https://stackoverflow.com/questions/994461/right-align-pad-numbers-in-bash) (see the second answer: https://stackoverflow.com/a/994953/1773798) – Renaud Pacalet Jun 21 '22 at 10:43

1 Answers1

3

Use printf; it allows format strings, including padding:

for n in 1 10 100 1000; do
    printf "Number=%6s\n" $n
done
Number=     1
Number=    10
Number=   100
Number=  1000
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380