<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>stefano &#187; Bash FTW</title> <atom:link href="http://www.stefanoforenza.com/tag/bash-ftw/feed/" rel="self" type="application/rss+xml" /><link>http://www.stefanoforenza.com</link> <description>Abbattuta l&#039;Accademia della Crusca gli SMS vinceranno</description> <lastBuildDate>Sun, 05 May 2013 00:47:22 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.5.1</generator> <item><title>How to repeat a shell command N times</title><link>http://www.stefanoforenza.com/how-to-repeat-a-shell-command-n-times/</link> <comments>http://www.stefanoforenza.com/how-to-repeat-a-shell-command-n-times/#comments</comments> <pubDate>Tue, 21 Dec 2010 10:02:01 +0000</pubDate> <dc:creator>Stefano Forenza</dc:creator> <category><![CDATA[ubuntu]]></category> <category><![CDATA[Bash FTW]]></category> <category><![CDATA[More time you save more you can waste]]></category> <category><![CDATA[[HOW TO] get the damn thing working]]></category> <guid
isPermaLink="false">http://www.stefanoforenza.com/?p=2137</guid> <description><![CDATA[Last day, I needed to repeat a shell command a arbitrary number of times, and all I found was the suggestion to use the repeat command. Sadly, I haven&#8217;t been able to found that command in Ubuntu, but after some research I could luckily find something useful. What follows is a very simple bash implementation of the repeat command. First, open your .bash_aliases file: xdg-open ~/.bash-aliases Second, paste these lines at the bottom of the file ...]]></description> <content:encoded><![CDATA[<p>Last day, I needed to <strong>repeat</strong> a <em>shell command</em> a arbitrary number of times, and all I found was the suggestion to use the <em>repeat</em> command.</p><p>Sadly, I haven&#8217;t been able to found that command in Ubuntu, but after some research I could luckily find something useful. What follows is a very simple <em>bash </em>implementation of the <em>repeat command. </em></p><p><strong>First</strong>, open your <em>.bash_aliases</em> file:</p><pre>xdg-open ~/.bash-aliases</pre><p><strong>Second</strong>, paste these lines at the bottom of the file and save:</p><pre>repeat() {
    n=$1
    shift
    while [ $(( n -= 1 )) -ge 0 ]
    do
        "$@"
    done
}</pre><p><strong>Third</strong>, either close and open again your terminal, <strong>or </strong>type:</p><pre>source ~/.bash_aliases</pre><p>Et voilà ! You can now <strong>use it like this</strong>:</p><pre>repeat 5 echo Hello World !!!</pre><p>or</p><pre>repeat 5 ./myscript.sh</pre><p>Hope this can help you !</p> ]]></content:encoded> <wfw:commentRss>http://www.stefanoforenza.com/how-to-repeat-a-shell-command-n-times/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>