<?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>MemoSoup &#187; Unix</title>
	<atom:link href="http://www.memosoup.com/category/scripts/unix-scripts/feed" rel="self" type="application/rss+xml" />
	<link>http://www.memosoup.com</link>
	<description>Mix of the things I always forget</description>
	<lastBuildDate>Thu, 09 Feb 2012 12:24:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>AIX: reset user password</title>
		<link>http://www.memosoup.com/20120130/aix-reset-user-password.html</link>
		<comments>http://www.memosoup.com/20120130/aix-reset-user-password.html#comments</comments>
		<pubDate>Mon, 30 Jan 2012 13:17:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[aix]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=446</guid>
		<description><![CDATA[<p>Change the password for the user (as root):</p> passwd username <p>Reset the login counter and unlock the user:</p> chsec -f /etc/security/lastlog -a &#34;unsuccessful_login_count=0&#34; -s username chuser &#34;account_locked=false&#34; username Tweet news and informations&#160;automotive,business,crime,health,life,politics,science,technology,travelautomotive,business,crime,health,life,politics,science,technology,travel]]></description>
			<content:encoded><![CDATA[<p>Change the password for the user (as root):</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">passwd</span> username</div></div>
<p>Reset the login counter and unlock the user:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">chsec <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>security<span style="color: #000000; font-weight: bold;">/</span>lastlog <span style="color: #660033;">-a</span> <span style="color: #ff0000;">&quot;unsuccessful_login_count=0&quot;</span> <span style="color: #660033;">-s</span> username<br />
chuser <span style="color: #ff0000;">&quot;account_locked=false&quot;</span> username</div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20120130%2Faix-reset-user-password.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20120130/aix-reset-user-password.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="AIX: reset user password" data-url="http://www.memosoup.com/20120130/aix-reset-user-password.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20120130/aix-reset-user-password.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix: print in color</title>
		<link>http://www.memosoup.com/20110130/unix-print-in-color.html</link>
		<comments>http://www.memosoup.com/20110130/unix-print-in-color.html#comments</comments>
		<pubDate>Sun, 30 Jan 2011 14:46:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=334</guid>
		<description><![CDATA[<p>This simple procedure takes 3 arguments as the parameters:</p> Text Foreground color Background color <p>It prints the text to the terminal in selected colors.</p> function print_color &#123; &#160;local text=$1 &#160;local fg=$2 &#160;local bg=$3 &#160;case &#34;$fg&#34; in &#160;red&#41; fg=&#34;31m&#34; ;; &#160;green&#41; fg=&#34;32m&#34; ;; &#160;yellow&#41; fg=&#34;33m&#34; ;; &#160;blue&#41; fg=&#34;34m&#34; ;; &#160;white&#41; fg=&#34;37m&#34; ;; &#160;black&#41; fg=&#34;30m&#34; ;; &#160;*&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>This simple procedure takes 3 arguments as the parameters:</p>
<ul>
<li>Text</li>
<li>Foreground color</li>
<li>Background color</li>
</ul>
<p>It prints the text to the terminal in selected colors.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> print_color <span style="color: #7a0874; font-weight: bold;">&#123;</span> <br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">text</span>=<span style="color: #007800;">$1</span> <br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">fg</span>=<span style="color: #007800;">$2</span> <br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">bg</span>=<span style="color: #007800;">$3</span> <br />
&nbsp;<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fg</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span> <br />
&nbsp;<span style="color: #c20cb9; font-weight: bold;">red</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">fg</span>=<span style="color: #ff0000;">&quot;31m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;green<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">fg</span>=<span style="color: #ff0000;">&quot;32m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;yellow<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">fg</span>=<span style="color: #ff0000;">&quot;33m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;blue<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">fg</span>=<span style="color: #ff0000;">&quot;34m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;white<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">fg</span>=<span style="color: #ff0000;">&quot;37m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;black<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">fg</span>=<span style="color: #ff0000;">&quot;30m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">fg</span>=<span style="color: #ff0000;">&quot;37m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;<span style="color: #000000; font-weight: bold;">esac</span> <br />
&nbsp;<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$bg</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span> <br />
&nbsp;<span style="color: #c20cb9; font-weight: bold;">red</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">bg</span>=<span style="color: #ff0000;">&quot;41m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;green<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">bg</span>=<span style="color: #ff0000;">&quot;42m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;yellow<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">bg</span>=<span style="color: #ff0000;">&quot;43m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;blue<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">bg</span>=<span style="color: #ff0000;">&quot;44m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;white<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">bg</span>=<span style="color: #ff0000;">&quot;47m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;black<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">bg</span>=<span style="color: #ff0000;">&quot;40m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">bg</span>=<span style="color: #ff0000;">&quot;40m&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span> <br />
&nbsp;<span style="color: #000000; font-weight: bold;">esac</span> <br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-en</span> <span style="color: #ff0000;">&quot;\033[<span style="color: #007800;">${fg}</span>\033[<span style="color: #007800;">${bg}</span><span style="color: #007800;">${text}</span>\033[0m&quot;</span> <br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20110130%2Funix-print-in-color.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20110130/unix-print-in-color.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Unix: print in color" data-url="http://www.memosoup.com/20110130/unix-print-in-color.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20110130/unix-print-in-color.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix: rename files to lowercase</title>
		<link>http://www.memosoup.com/20110130/unix-rename-files-to-lowercase.html</link>
		<comments>http://www.memosoup.com/20110130/unix-rename-files-to-lowercase.html#comments</comments>
		<pubDate>Sun, 30 Jan 2011 14:44:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=331</guid>
		<description><![CDATA[<p>It&#8217;s very simple to rename the files to lowercase/uppercase using awk:</p> <p>Lowercase</p> ls -1rt &#124; awk '{ printf(&#34;mv %s %s\n&#34;, $0, tolower($0)) &#124; &#34;sh&#34; } END { close(&#34;sh&#34;) }' <p>Uppercase</p> ls -1rt &#124; awk '{ printf(&#34;mv %s %s\n&#34;, $0, toupper($0)) &#124; &#34;sh&#34; } END { close(&#34;sh&#34;) }' Tweet news and informations&#160;automotive,business,crime,health,life,politics,science,technology,travelautomotive,business,crime,health,life,politics,science,technology,travel]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s very simple to rename the files to lowercase/uppercase using awk:</p>
<p><strong>Lowercase</strong></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1rt</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ printf(&quot;mv %s %s\n&quot;, $0, tolower($0)) | &quot;sh&quot; } END { close(&quot;sh&quot;) }'</span></div></div>
<p><strong>Uppercase</strong></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1rt</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ printf(&quot;mv %s %s\n&quot;, $0, toupper($0)) | &quot;sh&quot; } END { close(&quot;sh&quot;) }'</span></div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20110130%2Funix-rename-files-to-lowercase.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20110130/unix-rename-files-to-lowercase.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Unix: rename files to lowercase" data-url="http://www.memosoup.com/20110130/unix-rename-files-to-lowercase.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20110130/unix-rename-files-to-lowercase.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading password in Unix shell</title>
		<link>http://www.memosoup.com/20100202/reading-password-in-unix-shell.html</link>
		<comments>http://www.memosoup.com/20100202/reading-password-in-unix-shell.html#comments</comments>
		<pubDate>Tue, 02 Feb 2010 21:18:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=256</guid>
		<description><![CDATA[print -n &#34;Enter Your password:&#34; stty_orig=`stty -g` trap &#34;stty ${stty_orig}; exit&#34; 1 2 3 15 stty -echo &#62;&#38;- 2&#62;&#38;- read PASS stty ${stty_orig} &#62;&#38;- 2&#62;&#38;- trap 1 2 3 15 print <p>trap :catches interruptions. I.e. if the user presses Ctrl+C, the normal stty mode is set before stopping the program stty -echo :switches off the [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">print <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Enter Your password:&quot;</span><br />
<span style="color: #007800;">stty_orig</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">stty</span> -g<span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #ff0000;">&quot;stty <span style="color: #007800;">${stty_orig}</span>; exit&quot;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">2</span> <span style="color: #000000;">3</span> <span style="color: #000000;">15</span><br />
<span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #660033;">-echo</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span>- <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span>-<br />
<span style="color: #c20cb9; font-weight: bold;">read</span> PASS <br />
<span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #800000;">${stty_orig}</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span>- <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span>-<br />
<span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #000000;">1</span> <span style="color: #000000;">2</span> <span style="color: #000000;">3</span> <span style="color: #000000;">15</span><br />
print</div></div>
<p><strong>trap</strong>  :catches interruptions. I.e. if the user presses Ctrl+C, the normal stty mode is set before stopping the program<br />
<strong>stty -echo</strong>  :switches off the display echo<br />
<strong>&gt;&amp;- 2&gt;&amp;-</strong>  :helps to avoid <strong>&#8220;stty: Not a typewriter&#8221;</strong> message for non-interactive scripts.</p>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20100202%2Freading-password-in-unix-shell.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20100202/reading-password-in-unix-shell.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Reading password in Unix shell" data-url="http://www.memosoup.com/20100202/reading-password-in-unix-shell.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20100202/reading-password-in-unix-shell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix shell: workaround for loop problem</title>
		<link>http://www.memosoup.com/20100116/unix-shell-workaround-for-loop-problem.html</link>
		<comments>http://www.memosoup.com/20100116/unix-shell-workaround-for-loop-problem.html#comments</comments>
		<pubDate>Fri, 15 Jan 2010 23:04:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=247</guid>
		<description><![CDATA[<p>It&#8217;s not possible to get the value of the loop variables in some versions of ksh.</p> <p>Example:</p> #!/bin/ksh num=0 cat $0 &#124; while read line ; do &#160;let num=num+1 done echo &#34;Number=$num&#34; <p>This script will return &#8220;Number=0&#8243; as the result on some Linux machines.</p> <p>Here is the workaround for the problem: You should change the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not possible to get the value of the loop variables in some versions of ksh.</p>
<p>Example:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/ksh</span><br />
<br />
<span style="color: #007800;">num</span>=<span style="color: #000000;">0</span><br />
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$0</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line ; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">num</span>=num+<span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Number=<span style="color: #007800;">$num</span>&quot;</span></div></div>
<p>This script will return &#8220;Number=0&#8243; as the result on some Linux machines.</p>
<p>Here is the workaround for the problem: You should change the redirection method for the input file.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/ksh</span><br />
<br />
<span style="color: #007800;">l</span>=<span style="color: #000000;">0</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line ; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">l</span>=l+<span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$0</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Number=<span style="color: #007800;">$l</span>&quot;</span></div></div>
<p>The last script will return the correct result: &#8220;Number=9&#8243;</p>
<p>Another possibility is to use the named pipe:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/ksh</span><br />
<br />
<span style="color: #007800;">TMPPIPE</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>thepipe.<span style="color: #007800;">$$</span><br />
<span style="color: #c20cb9; font-weight: bold;">mkfifo</span> <span style="color: #007800;">$TMPPIPE</span><br />
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$0</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TMPPIPE</span> <span style="color: #000000; font-weight: bold;">&amp;</span><br />
<span style="color: #007800;">num</span>=<span style="color: #000000;">0</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line ; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">num</span>=num+<span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$TMPPIPE</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Number=<span style="color: #007800;">$num</span>&quot;</span></div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20100116%2Funix-shell-workaround-for-loop-problem.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20100116/unix-shell-workaround-for-loop-problem.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Unix shell: workaround for loop problem" data-url="http://www.memosoup.com/20100116/unix-shell-workaround-for-loop-problem.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20100116/unix-shell-workaround-for-loop-problem.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix: get the file date</title>
		<link>http://www.memosoup.com/20090918/unix-get-the-file-date.html</link>
		<comments>http://www.memosoup.com/20090918/unix-get-the-file-date.html#comments</comments>
		<pubDate>Fri, 18 Sep 2009 15:08:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=132</guid>
		<description><![CDATA[ls -1 &#124; cpio -o &#124; cpio -ivt &#124; awk '{print $NF, $(NF-1), $(NF-4), $(NF-3) }' <p>Warning: I/O expensive for the large files!</p> <p>Perl:</p> @a = localtime&#40;&#40;stat&#40;$my_file&#41;&#41;&#91;9&#93;&#41;; $a&#91;4&#93;++; printf &#34;%02d%02d%02d&#34;,@a&#91;5,4,3&#93;; Tweet news and informations&#160;automotive,business,crime,health,life,politics,science,technology,travelautomotive,business,crime,health,life,politics,science,technology,travel]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cpio</span> <span style="color: #660033;">-o</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cpio</span> <span style="color: #660033;">-ivt</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $NF, $(NF-1), $(NF-4), $(NF-3) }'</span></div></div>
<p><strong>Warning: </strong>I/O expensive for the large files!</p>
<p><strong>Perl:</strong></p>
<div class="codecolorer-container perl default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">@a</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/localtime.html"><span style="color: #000066;">localtime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/stat.html"><span style="color: #000066;">stat</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$my_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span><br />
<a href="http://perldoc.perl.org/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #ff0000;">&quot;%02d%02d%02d&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">@a</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20090918%2Funix-get-the-file-date.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20090918/unix-get-the-file-date.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Unix: get the file date" data-url="http://www.memosoup.com/20090918/unix-get-the-file-date.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20090918/unix-get-the-file-date.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Redirect script output to the log</title>
		<link>http://www.memosoup.com/20090913/redirect-script-output-to-the-log.html</link>
		<comments>http://www.memosoup.com/20090913/redirect-script-output-to-the-log.html#comments</comments>
		<pubDate>Sun, 13 Sep 2009 17:29:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=87</guid>
		<description><![CDATA[<p>If the whole output of the complex script should be redirected to the log, the following trick could be used.</p> if &#91; &#34;$1&#34; != &#34;-log&#34; &#93; ; then &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;$0 -log &#34;$@&#34; 2&#62;&#38;1 &#124; tee the_log_file.$$.log &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;
&#160; &#160;echo &#34;The log file for the current session: the_log_file.$$.log&#34; &#160;
&#160; &#160;exit 0 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 
fi &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 
shift &#160;# remove &#34;-log&#34; parameter
 
				
			 
				
			 
				Tweet 
			
		news and informations&#160;automotive,business,crime,health,life,politics,science,technology,travelautomotive,business,crime,health,life,politics,science,technology,travel]]></description>
			<content:encoded><![CDATA[<p>If the whole output of the complex script should be redirected to the log, the following trick could be used.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;-log&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;<span style="color: #007800;">$0</span> <span style="color: #660033;">-log</span> <span style="color: #ff0000;">&quot;$@&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> the_log_file.<span style="color: #007800;">$$</span>.log &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The log file for the current session: the_log_file.$$.log&quot;</span> &nbsp;<br />
&nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #000000; font-weight: bold;">fi</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #7a0874; font-weight: bold;">shift</span> &nbsp;<span style="color: #666666; font-style: italic;"># remove &quot;-log&quot; parameter</span></div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20090913%2Fredirect-script-output-to-the-log.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20090913/redirect-script-output-to-the-log.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Redirect script output to the log" data-url="http://www.memosoup.com/20090913/redirect-script-output-to-the-log.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20090913/redirect-script-output-to-the-log.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>grep in find command: how to display file names</title>
		<link>http://www.memosoup.com/20090913/grep-in-find-command-how-to-display-file-names.html</link>
		<comments>http://www.memosoup.com/20090913/grep-in-find-command-how-to-display-file-names.html#comments</comments>
		<pubDate>Sat, 12 Sep 2009 22:09:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[filename]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=73</guid>
		<description><![CDATA[<p>Here is very simple trick to force the grep command to display file name, when it&#8217;s used together with find operation. Just write /dev/null as the &#8220;second file&#8221;</p> <p>find . -type f -exec grep somestring {} /dev/null \;</p> Tweet news and informations&#160;automotive,business,crime,health,life,politics,science,technology,travelautomotive,business,crime,health,life,politics,science,technology,travel]]></description>
			<content:encoded><![CDATA[<p>Here is very simple trick to force the grep command to display file name, when it&#8217;s used together with <strong>find</strong> operation.<br />
Just write <strong>/dev/null</strong> as the &#8220;second file&#8221;</p>
<p>find . -type f -exec grep <em>somestring</em> {} <strong>/dev/null</strong> \;</p>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20090913%2Fgrep-in-find-command-how-to-display-file-names.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20090913/grep-in-find-command-how-to-display-file-names.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="grep in find command: how to display file names" data-url="http://www.memosoup.com/20090913/grep-in-find-command-how-to-display-file-names.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20090913/grep-in-find-command-how-to-display-file-names.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using pattern lists in Unix</title>
		<link>http://www.memosoup.com/20090912/using-pattern-lists-in-unix.html</link>
		<comments>http://www.memosoup.com/20090912/using-pattern-lists-in-unix.html#comments</comments>
		<pubDate>Sat, 12 Sep 2009 18:57:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=71</guid>
		<description><![CDATA[<p>Here is the small reminder about the syntax of the &#8220;case&#8221; command and the usage of the pattern lists.</p> #!/bin/ksh print -n &#34;Please enter the line: &#34; read line case &#34;$line&#34; in &#160;?&#40;dog&#124;cat&#41; &#160;&#41; print &#34;zero or one occurrence of any pattern&#34; ;; &#160;*&#40;low&#124;high&#41; &#41; print &#34;zero or more occurrences of any pattern&#34; ;; &#160;@&#40;duncan&#124;methos&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the small reminder about the syntax of the &#8220;case&#8221; command and the usage of the pattern lists.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/ksh</span><br />
print <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Please enter the line: &quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">read</span> line<br />
<br />
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$line</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span><br />
&nbsp;?<span style="color: #7a0874; font-weight: bold;">&#40;</span>dog<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">cat</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp;<span style="color: #7a0874; font-weight: bold;">&#41;</span> print <span style="color: #ff0000;">&quot;zero or one occurrence of any pattern&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>low<span style="color: #000000; font-weight: bold;">|</span>high<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> print <span style="color: #ff0000;">&quot;zero or more occurrences of any pattern&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>duncan<span style="color: #000000; font-weight: bold;">|</span>methos<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> print <span style="color: #ff0000;">&quot;exactly one occurrence of any pattern&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp;+<span style="color: #7a0874; font-weight: bold;">&#40;</span>rudolph<span style="color: #000000; font-weight: bold;">|</span>blitzen<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> print <span style="color: #ff0000;">&quot;one or more occurrence of any pattern&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">!</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>grinch<span style="color: #000000; font-weight: bold;">|</span>babay<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> print <span style="color: #ff0000;">&quot;everything except patterns&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp;-<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>hH?<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp;print <span style="color: #ff0000;">&quot;Some help...&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp;-v<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>erbose<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> print <span style="color: #ff0000;">&quot;Some more words...&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> print <span style="color: #ff0000;">&quot;Something else...&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">esac</span></div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20090912%2Fusing-pattern-lists-in-unix.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20090912/using-pattern-lists-in-unix.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Using pattern lists in Unix" data-url="http://www.memosoup.com/20090912/using-pattern-lists-in-unix.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20090912/using-pattern-lists-in-unix.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Print the PATH directories in the readable format</title>
		<link>http://www.memosoup.com/20090912/print-the-path-directories-in-the-readable-format.html</link>
		<comments>http://www.memosoup.com/20090912/print-the-path-directories-in-the-readable-format.html#comments</comments>
		<pubDate>Sat, 12 Sep 2009 18:55:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[PATH]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=69</guid>
		<description><![CDATA[echo $PATH&#124; awk -v RS=&#34;:&#34; '{ print $0 }' echo $LD_LIBRARY_PATH &#124;awk -v RS=&#34;:&#34; '{ system ( &#34;ls -rltd &#34; $0 ) }' <p>Warning! As far as the option &#8216;-v&#8217; is used, the new awk(nawk in some systems) should be used.</p> <p>To check if the new version of awk is installed:</p> awk 1 /dev/null <p>The [...]]]></description>
			<content:encoded><![CDATA[<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$PATH</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">RS</span>=<span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{ print $0 }'</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$LD_LIBRARY_PATH</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-v</span> <span style="color: #007800;">RS</span>=<span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{ system ( &quot;ls -rltd &quot; $0 ) }'</span></div></div>
<p><em>Warning!</em><br />
As far as the option &#8216;-v&#8217; is used, the new awk(<strong>nawk</strong> in some systems) should be used.</p>
<p>To check if the new version of awk is installed:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</div></div>
<p>The output will be empty for new awk.<br />
You have the old awk, if the output is something like</p>
<blockquote><p>
awk: syntax error near line 1
</p></blockquote>
<p>In this case <strong>nawk</strong> should be used instead <strong>awk</strong></p>
<p><strong>MS-DOS</strong> modification: echo %PATH% | awk -v RS=&#8221;;&#8221; &#8220;{ print $0 }&#8221;</p>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20090912%2Fprint-the-path-directories-in-the-readable-format.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20090912/print-the-path-directories-in-the-readable-format.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="Print the PATH directories in the readable format" data-url="http://www.memosoup.com/20090912/print-the-path-directories-in-the-readable-format.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20090912/print-the-path-directories-in-the-readable-format.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

