0

is there possibility to write character multiple times? For example if i would like to print b on the same line x-times and the value of how many times this character is supposed to be printed would be in variable. So is there something like... numberoftimes=5

character * numberoftimes would look like that

bbbbb

jerry
  • 21
  • 3

1 Answers1

0

The most straightforward approach would be to use a loop.

numberoftimes=5
char=b
for ((i=0; i < numberoftimes; i++)); do printf '%s' "$char"; done
chepner
  • 497,756
  • 71
  • 530
  • 681