Is there any built-in linux command that allows to output a string that is n times an input string??
|
|
|||||||||||||
|
|
Here's an old-fashioned way that's pretty portable:
This is a more conventional version of Adrian Petrescu's answer using brace expansion:
That's equivalent to:
This is a little more concise and dynamic version of pike's answer:
|
|||||||
|
|
Perhaps another way that is more general and useful for you:
The bash shell is more powerful than most people think :) |
|||||
|
|
Quite a few good ways already mentioned. Can't forget about good old [john@awesome]$for i in `seq 5`; do echo "Hi";done Hi Hi Hi Hi Hi |
||||
|
|
|
repeat
|
|||
|
|
|
This can be parameterized and doesn't require a temp variable, FWIW:
Or, if
|
|||
|
|
|
Not exactly built in to linux, but if you have python installed..
|
|||||||||
|
|
Try this one:
Will create (a hundred dash): |
|||
|
|
outputs
|
|||
|
Where # is the number in seconds you want the command to be repeated. |
||||
|
|
|
Assuming you want something like Perl's
I explicitly used a |
||||
|
|
|
You can use a trick. Echoing an empty variable does not print anything. So you can write:
If |
||||
|
|
|
based on what @pike was hinting at for every character in string echo string
An example of a heading underlined with
will output
This seems to port between linux and OS X and that makes me happy. nJoy! |
|||
|
|

