How can I repeat the character - n times in shell? I have read and tried this, but this does not work for -. It throws error invalid option>
-
invalid option>
Use a for loop and number range:
for
for i in {1..10}; do echo "-"; done
Or on a single line:
for i in {1..10}; do echo -n "-"; done
which outputs ----------.
----------
EDIT: This was before your printf edit.
printf