0

I want to print a sequence of - characters.

Have done

printf '=%.0s' {1..55}

But get no printing with

printf '-%.0s' {1..55}
Dilna
  • 405
  • 1
  • 6
  • Would it be possible to insert a newline at the end? – Dilna Mar 19 '23 at 17:16
  • on my system the 2nd `printf` generates a syntax error; if this happens on your system then consider updating the question to show the complete output when running the 2nd `printf` – markp-fuso Mar 19 '23 at 17:27
  • See [How can I repeat a character in Bash?](https://stackoverflow.com/q/5349718/4154375) for other ways to repeat a character. – pjh Mar 19 '23 at 19:04

2 Answers2

1

printf accepts arguments. '-%s' is recognized as an option, which is an invalid one.

You can use -- to mark the end of command options:

printf -- '-%.0s' {1..55}
Maroun
  • 94,125
  • 30
  • 188
  • 241
0

Here is an alternative method:

printf -v blanks '%55s' ''
echo ${blanks// /-}
M. Nejat Aydin
  • 9,597
  • 1
  • 7
  • 17