Linux command to repeat a string n times - Super User

2010-07-20 108 words 1 min read

I was working on something and needed to output the string n times. I have required this even to print a line with ’-’ or ’=’ but this time I badly wanted it in bash. So I searched google and found this:

printf ”Amit Agarwal%.0s” {1..5}

Explanations and other examples: <a href="http://superuser.com/questions/86340/linux-command-to-repeat-a-string-n-times">http://superuser.com/questions/86340/linux-command-to-repeat-a-string-n-times<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://www.rateitall.com/i-3177235-flat-rate-us-terminations.aspx">1 reviews of Flat-Rate US Terminations (rateitall.com) <li class="zemanta-article-ul-li"><a href="http://www.brighthub.com/computing/linux/articles/75743.aspx">Top Linux GUI (brighthub.com) <li class="zemanta-article-ul-li"><a href="http://www.gnu.org/software/emacs/tour/">A guided tour of Emacs (gnu.org) <div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/zemified_e6.png" alt="Enhanced by Zemanta" /><span class="zem-script more-related pretty-attribution">


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it