2

If I want to print 60 dashes.

Somehow like

echo "-" * 60.

How can I do with this? Thanks.

Jam
  • 113
  • 2
  • 7
  • For bash [stackoverflow.com/questions/5349718/how-can-i-repeat-a-character-in-bash] (http://stackoverflow.com/questions/5349718/how-can-i-repeat-a-character-in-bash) – miltonb Apr 22 '16 at 00:06

2 Answers2

3
printf "%*s" 60 "" | tr " " "-"

The printf command prints an empty string padded with spaces to fit a width of 60. Then tr converts the spaces to dashes.

This does not print a trailing newline. If you want one, add ;echo to the end of the command.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
1

printf '%s\n' $(dd if=/dev/zero count=60 status=none | tr '\000' '-')

zwol
  • 135,547
  • 38
  • 252
  • 361