Easiest and shortest way without a loop
VAR=15
Prints as many dots as VAR says (change the first dot to any other character if you like) with eval :
eval printf '.%.0s' {1..$VAR}
Saves the dotted line in a variable to be used later:
line=$(eval printf '.%.0s' {1..$VAR})
echo "Sign here $line"
-Blatantly stolen from dogbane's answer https://stackoverflow.com/a/5349842/3319298
Edit 1 Note about brace expansions like {1..N} - they are performed early and do NOT expand $VAR, thus the use of eval. The use of eval in a script has security implications, be cautious.
Edit 2: Since I have now switched to fish shell, here is a function defined in config.fish that does this with convenience in that shell:
function line -a char -a length
printf '%*s\n' $length "" | tr ' ' $char
end
Usage: line = 8 produces ========, line \" 8 produces """""""".
zshat least,{1..$length}works just fine.bindkeywith^[[Dto move the cursor back into a useful place!