<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments on: Bash For Loop Examples</title> <atom:link href="http://www.cyberciti.biz/faq/bash-for-loop/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/bash-for-loop/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 11:20:49 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-67620</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Fri, 27 Jan 2012 10:07:15 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-67620</guid> <description>Hi Ram,
Since you are a real beginner, you would really take great benefit self-training on this course free of charge by vivek &amp; contributors:
http://bash.cyberciti.biz/guide/Main_Page
--P</description> <content:encoded><![CDATA[<p>Hi Ram,</p><p>Since you are a real beginner, you would really take great benefit self-training on this course free of charge by vivek &amp; contributors:<br
/> <a
href="http://bash.cyberciti.biz/guide/Main_Page" rel="nofollow">http://bash.cyberciti.biz/guide/Main_Page</a></p><p>&#8211;P</p> ]]></content:encoded> </item> <item><title>By: Anthony Thyssen</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-67619</link> <dc:creator>Anthony Thyssen</dc:creator> <pubDate>Fri, 27 Jan 2012 07:48:10 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-67619</guid> <description>Note that is you want to append a string that does not start with a &#039;.&#039; (for example the string &quot;_info.txt&quot;) then you need to delimit the variable name....
for i in *; do mv &quot;$i&quot; &quot;${i}_info.txt&quot;; done</description> <content:encoded><![CDATA[<p>Note that is you want to append a string that does not start with a &#8216;.&#8217; (for example the string &#8220;_info.txt&#8221;) then you need to delimit the variable name&#8230;.</p><p>for i in *; do mv &#8220;$i&#8221; &#8220;${i}_info.txt&#8221;; done</p> ]]></content:encoded> </item> <item><title>By: maxy-millianne</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-67483</link> <dc:creator>maxy-millianne</dc:creator> <pubDate>Tue, 24 Jan 2012 06:18:28 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-67483</guid> <description>Of course, if you want to worry about files with spaces in (and other things?), put quote around the arguments to mv, as in the gp.</description> <content:encoded><![CDATA[<p>Of course, if you want to worry about files with spaces in (and other things?), put quote around the arguments to mv, as in the gp.</p> ]]></content:encoded> </item> <item><title>By: Ram</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-66611</link> <dc:creator>Ram</dc:creator> <pubDate>Tue, 10 Jan 2012 18:57:57 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-66611</guid> <description>Hi Vivek,
i am trying to run the below code as ram.sh in server as $ sh ./ram.sh
code:
-------------------------
#!/bin/bash
for i in 1 2 4
do
echo &quot;Welcome $i times&quot;
done
-------------------------
It fails saying
ram.sh: line 3: syntax error near unexpected token `do
ram.sh: line 3: `do
is that something i need to check which version is the sh and bash used in the server. how to check that.
it is a pretty simple code and it is not workign.
i am running this script in Linux server 64 bit server.</description> <content:encoded><![CDATA[<p>Hi Vivek,<br
/> i am trying to run the below code as ram.sh in server as $ sh ./ram.sh</p><p>code:</p><p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br
/> #!/bin/bash<br
/> for i in 1 2 4<br
/> do<br
/> echo &#8220;Welcome $i times&#8221;<br
/> done<br
/> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p><p>It fails saying<br
/> ram.sh: line 3: syntax error near unexpected token `do<br
/> ram.sh: line 3: `do</p><p>is that something i need to check which version is the sh and bash used in the server. how to check that.<br
/> it is a pretty simple code and it is not workign.<br
/> i am running this script in Linux server 64 bit server.</p> ]]></content:encoded> </item> <item><title>By: andreea</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-66511</link> <dc:creator>andreea</dc:creator> <pubDate>Sun, 08 Jan 2012 20:54:19 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-66511</guid> <description>I have this code that shows the first column  which represents the number of insertions of a commit and calculate the sum of all numbers of each line.
if [ $# -eq 2 ]; then
if [ $2 = &quot;added_lines&quot; ]; then
tmpfile=$(mktemp)
sum=0
git log --pretty=tformat: --numstat &#124; tr -s &quot;\n&quot; &#124; cut -f 1 &gt; $tmpfile
for i in $(cat $tmpfile); do
sum=$(($sum + $i))
done
echo &quot;$sum&quot;
rm $tmpfile
But with &#039;cut -f 1&#039; it takes too much time to calculate and to show the result.Can you help me saying how can i do this with &#039;awk&#039; or &#039;gawk&#039;?
Please help me.Thanks</description> <content:encoded><![CDATA[<p>I have this code that shows the first column  which represents the number of insertions of a commit and calculate the sum of all numbers of each line.<br
/> if [ $# -eq 2 ]; then<br
/> if [ $2 = "added_lines" ]; then<br
/> tmpfile=$(mktemp)<br
/> sum=0<br
/> git log &#8211;pretty=tformat: &#8211;numstat | tr -s &#8220;\n&#8221; | cut -f 1 &gt; $tmpfile<br
/> for i in $(cat $tmpfile); do<br
/> sum=$(($sum + $i))<br
/> done<br
/> echo &#8220;$sum&#8221;<br
/> rm $tmpfile<br
/> But with &#8216;cut -f 1&#8242; it takes too much time to calculate and to show the result.Can you help me saying how can i do this with &#8216;awk&#8217; or &#8216;gawk&#8217;?<br
/> Please help me.Thanks</p> ]]></content:encoded> </item> <item><title>By: andreea</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-66467</link> <dc:creator>andreea</dc:creator> <pubDate>Fri, 06 Jan 2012 18:33:21 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-66467</guid> <description>Thanks for your quick answer.
I have another problem.i have to use this script by using git.can you explain me or give some advices how can i use it?thank you very much.</description> <content:encoded><![CDATA[<p>Thanks for your quick answer.<br
/> I have another problem.i have to use this script by using git.can you explain me or give some advices how can i use it?thank you very much.</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-66420</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Thu, 05 Jan 2012 18:23:14 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-66420</guid> <description>&quot;infamous&quot; was a private joke-understatement
Sorry, no offense intended!
Vivek website roxxxxs !
-- Philippe</description> <content:encoded><![CDATA[<p>&#8220;infamous&#8221; was a private joke-understatement<br
/> Sorry, no offense intended!<br
/> Vivek website roxxxxs !</p><p>&#8211; Philippe</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-66418</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Thu, 05 Jan 2012 17:33:19 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-66418</guid> <description>Dear andreea
1) I quote Vivek: &quot;You are free to use our shell scripting forum for questions.&quot;
http://nixcraft.com/shell-scripting/
2) You can learn for free shell scripting with the infamous Vivek&#039;s collaborative Linux Shell Scripting Tutorial
http://bash.cyberciti.biz/guide/Main_Page
Enjoy!
-- Philippe</description> <content:encoded><![CDATA[<p>Dear andreea</p><p>1) I quote Vivek: &#8220;You are free to use our shell scripting forum for questions.&#8221;<br
/> <a
href="http://nixcraft.com/shell-scripting/" rel="nofollow">http://nixcraft.com/shell-scripting/</a></p><p>2) You can learn for free shell scripting with the infamous Vivek&#8217;s collaborative Linux Shell Scripting Tutorial<br
/> <a
href="http://bash.cyberciti.biz/guide/Main_Page" rel="nofollow">http://bash.cyberciti.biz/guide/Main_Page</a></p><p>Enjoy!</p><p>&#8211; Philippe</p> ]]></content:encoded> </item> <item><title>By: andreea</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-66417</link> <dc:creator>andreea</dc:creator> <pubDate>Thu, 05 Jan 2012 16:21:04 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-66417</guid> <description>Hello!
i am beginner and i have to make a bash script in which i have to show the number of lines that were added by the analized commits(in git).can you help me?Thanks.</description> <content:encoded><![CDATA[<p>Hello!<br
/> i am beginner and i have to make a bash script in which i have to show the number of lines that were added by the analized commits(in git).can you help me?Thanks.</p> ]]></content:encoded> </item> <item><title>By: Akshit</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-65270</link> <dc:creator>Akshit</dc:creator> <pubDate>Wed, 07 Dec 2011 12:36:08 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-65270</guid> <description>Hi...
Thanks for the article, it is helpful really.
I want to know one thing.
Let&#039;s say there is file with content
1
2
3
4
5
how can I use for loop and print these numbers?
If you are understanding what I am trying to tell. I want to use the contents of these files and stored in the variable.</description> <content:encoded><![CDATA[<p>Hi&#8230;<br
/> Thanks for the article, it is helpful really.</p><p>I want to know one thing.<br
/> Let&#8217;s say there is file with content<br
/> 1<br
/> 2<br
/> 3<br
/> 4<br
/> 5</p><p>how can I use for loop and print these numbers?<br
/> If you are understanding what I am trying to tell. I want to use the contents of these files and stored in the variable.</p> ]]></content:encoded> </item> <item><title>By: Hannah</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-65210</link> <dc:creator>Hannah</dc:creator> <pubDate>Mon, 05 Dec 2011 23:21:12 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-65210</guid> <description>Hi all... I have a question about using for loops.  Basically, I have a file containing a list of protein ID numbers.  what I want to do is create a for loop that can go into this file, grab each protein ID number, and then search the NCBI database to get the fasta sequence of each protein... and then create another file containing all of the fasta sequences....
In general, my problem is that I can&#039;t figure out how to get the protein ID numbers from the output file (ex. $1 in file1) into the for loop script.
This is what I have so far:
for gi in file1
do
fastacmd -d /data/nr -s gi
done
but I need to specify that the gi (protein ID number) is the first column ($1) of file1.
Does this make sense?</description> <content:encoded><![CDATA[<p>Hi all&#8230; I have a question about using for loops.  Basically, I have a file containing a list of protein ID numbers.  what I want to do is create a for loop that can go into this file, grab each protein ID number, and then search the NCBI database to get the fasta sequence of each protein&#8230; and then create another file containing all of the fasta sequences&#8230;.</p><p>In general, my problem is that I can&#8217;t figure out how to get the protein ID numbers from the output file (ex. $1 in file1) into the for loop script.</p><p>This is what I have so far:</p><p>for gi in file1<br
/> do<br
/> fastacmd -d /data/nr -s gi<br
/> done</p><p>but I need to specify that the gi (protein ID number) is the first column ($1) of file1.</p><p>Does this make sense?</p> ]]></content:encoded> </item> <item><title>By: Sonia McMath</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-64564</link> <dc:creator>Sonia McMath</dc:creator> <pubDate>Fri, 18 Nov 2011 06:52:02 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-64564</guid> <description>Great weblog right here! Additionally your web site quite a bit up very fast! What host are you the usage of? Can I get your associate hyperlink for your host? I want my website loaded up as fast as yours lol</description> <content:encoded><![CDATA[<p>Great weblog right here! Additionally your web site quite a bit up very fast! What host are you the usage of? Can I get your associate hyperlink for your host? I want my website loaded up as fast as yours lol</p> ]]></content:encoded> </item> <item><title>By: Vivek Gite</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-63871</link> <dc:creator>Vivek Gite</dc:creator> <pubDate>Tue, 25 Oct 2011 11:19:02 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-63871</guid> <description>GNU/Bash v4.2.8 does supports {1..5} syntax. What is the output of the following commands?
&lt;pre&gt;ls -l /bin/bash
/bin/bash --version&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>GNU/Bash v4.2.8 does supports {1..5} syntax. What is the output of the following commands?</p><pre>ls -l /bin/bash
/bin/bash --version</pre>]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-63869</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Tue, 25 Oct 2011 09:01:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-63869</guid> <description>This code has to be written into a text file, which must be made executable.
Did you do that?</description> <content:encoded><![CDATA[<p>This code has to be written into a text file, which must be made executable.<br
/> Did you do that?</p> ]]></content:encoded> </item> <item><title>By: ptrac3</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-63856</link> <dc:creator>ptrac3</dc:creator> <pubDate>Mon, 24 Oct 2011 17:43:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-63856</guid> <description>Very handful tutorial! : ) But i&#039;ve got a problem on my Ubuntu linux box, a strange problem.. Executing the example code
#!/bin/bash
for i in {1..5}
do
echo &quot;Welcome $i times&quot;
done
i get as output Welcome {1..5} times. So the bash doesn&#039;t understand the range {1..5}...Have any idea? My bash version is GNU bash, version 4.2.8(1)-release (x86_64-pc-linux-gnu). Thank u : )</description> <content:encoded><![CDATA[<p>Very handful tutorial! : ) But i&#8217;ve got a problem on my Ubuntu linux box, a strange problem.. Executing the example code</p><p>#!/bin/bash<br
/> for i in {1..5}<br
/> do<br
/> echo &#8220;Welcome $i times&#8221;<br
/> done</p><p>i get as output Welcome {1..5} times. So the bash doesn&#8217;t understand the range {1..5}&#8230;Have any idea? My bash version is GNU bash, version 4.2.8(1)-release (x86_64-pc-linux-gnu). Thank u : )</p> ]]></content:encoded> </item> <item><title>By: Nagesh</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-62416</link> <dc:creator>Nagesh</dc:creator> <pubDate>Wed, 14 Sep 2011 10:21:45 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-62416</guid> <description>This post is 3 yrs old but still RockS.\m/</description> <content:encoded><![CDATA[<p>This post is 3 yrs old but still RockS.\m/</p> ]]></content:encoded> </item> <item><title>By: ITtuition.com</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-61483</link> <dc:creator>ITtuition.com</dc:creator> <pubDate>Thu, 11 Aug 2011 13:30:06 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-61483</guid> <description>Spot on. Included all examples that form a good base. Thanks for sharing.</description> <content:encoded><![CDATA[<p>Spot on. Included all examples that form a good base. Thanks for sharing.</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-61474</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Thu, 11 Aug 2011 08:48:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-61474</guid> <description>You could start learning shell scripting:
About [for] loops: http://bash.cyberciti.biz/guide/For_loop
( from that excellent http://bash.cyberciti.biz/guide/Main_Page )
Enjoy!</description> <content:encoded><![CDATA[<p>You could start learning shell scripting:</p><p>About [for] loops: <a
href="http://bash.cyberciti.biz/guide/For_loop" rel="nofollow">http://bash.cyberciti.biz/guide/For_loop</a></p><p>( from that excellent <a
href="http://bash.cyberciti.biz/guide/Main_Page" rel="nofollow">http://bash.cyberciti.biz/guide/Main_Page</a> )</p><p>Enjoy!</p> ]]></content:encoded> </item> <item><title>By: Sam McAllister</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-61471</link> <dc:creator>Sam McAllister</dc:creator> <pubDate>Thu, 11 Aug 2011 07:47:27 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-61471</guid> <description>Haha ok thanks :)</description> <content:encoded><![CDATA[<p>Haha ok thanks :)</p> ]]></content:encoded> </item> <item><title>By: Anthony Thyssen</title><link>http://www.cyberciti.biz/faq/bash-for-loop/#comment-61470</link> <dc:creator>Anthony Thyssen</dc:creator> <pubDate>Thu, 11 Aug 2011 07:25:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=2284#comment-61470</guid> <description>Start a new thread!</description> <content:encoded><![CDATA[<p>Start a new thread!</p> ]]></content:encoded> </item> </channel> </rss>
