<?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>Linux, Open Source and Web 2.0 &#187; shell</title>
	<atom:link href="http://www.itecsoftware.com/tag/shell/feed" rel="self" type="application/rss+xml" />
	<link>http://www.itecsoftware.com</link>
	<description>Itec Software</description>
	<lastBuildDate>Wed, 16 Nov 2011 02:18:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Bash Shell Script to Loop Over Set of Files</title>
		<link>http://www.itecsoftware.com/bash-shell-loop-over-set-of-files?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bash-shell-loop-over-set-of-files</link>
		<comments>http://www.itecsoftware.com/bash-shell-loop-over-set-of-files#comments</comments>
		<pubDate>Sat, 27 Jun 2009 16:04:07 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=165</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/bash-shell-loop-over-set-of-files" title="Bash Shell Script to Loop Over Set of Files"></a>I&#8217;m often asked how to write a shell script that loops over a set of files in the current directory and perform some actions on them. Really, nothing is simpler than that, it&#8217;s just that most administrators or developers don&#8217;t &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/bash-shell-loop-over-set-of-files">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/bash-shell-loop-over-set-of-files" title="Bash Shell Script to Loop Over Set of Files"></a><!-- google_ad_section_start --><p>I&#8217;m often asked how to write a shell script that loops over a set of files in the current directory and perform some actions on them. Really, nothing is simpler than that, it&#8217;s just that most administrators or developers don&#8217;t take the time to get into shell scripting.</p>
<p>The simplest form is this, simply change the wildcard characters to match your requirements:</p>
<pre class="bash"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">FILES=</span><span style="color: #ff0000;">"*.txt"</span>
<span style="color: #000000; font-weight: bold;">for</span> f <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #ff0000;">$FILES</span>
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">"Processing $f ..."</span>
  <span style="color: #808080; font-style: italic;"># perform some action on each <span style="color: #c20cb9; font-weight: bold;">file</span>. <span style="color: #007800;">$f</span> stores the current <span style="color: #c20cb9; font-weight: bold;">file</span> name</span>
<span style="color: #7a0874; font-weight: bold;">  echo</span> <span style="color: #ff0000;">"Done processing $f ..."</span>
<span style="color: #000000; font-weight: bold;">done</span></pre>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/bash-shell-loop-over-set-of-files/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 3/11 queries in 0.004 seconds using memcached
Object Caching 389/401 objects using memcached

Served from: www.itecsoftware.com @ 2012-02-08 18:20:47 -->
