<?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>S.G. Vulcan &#187; Bash scripting</title>
	<atom:link href="http://www.sgvulcan.com/category/systems/nix/bash-scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sgvulcan.com</link>
	<description>Silviu&#039;s tech blog. Resources and informations about linux, windows, symbian systems, networks, reviews, microcontrollers, and more.</description>
	<lastBuildDate>Wed, 08 Feb 2012 09:39:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Search and replace text in many files</title>
		<link>http://www.sgvulcan.com/search-and-replace-text-in-many-files/</link>
		<comments>http://www.sgvulcan.com/search-and-replace-text-in-many-files/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 07:48:46 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=1864</guid>
		<description><![CDATA[This is a handy one liner that searches and replaces text in multiple files. (You can use find for example to run it in multiple folders) View Code BASH1 perl -pi -e 's/old_text/new_text/g' *.conf This line replaces old_text with new_text in all the .conf files in the current folder. Of course you can use regular expressions.]]></description>
			<content:encoded><![CDATA[<p>This is a handy one liner that searches and replaces text in multiple files. (You can use <a href="http://manpages.sgvulcan.com/find.1.php">find</a> for example to run it in multiple folders)</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1864code2'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p18642"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1864code2"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-pi</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/old_text/new_text/g'</span> <span style="color: #000000; font-weight: bold;">*</span>.conf</pre></td></tr></table></div>

<p>This line replaces old_text with new_text in all the .conf files in the current folder. Of course you can use regular expressions.</p>
<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/search-and-replace-text-in-many-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickly check if a process is running or not</title>
		<link>http://www.sgvulcan.com/quickly-check-if-a-process-is-running-or-not/</link>
		<comments>http://www.sgvulcan.com/quickly-check-if-a-process-is-running-or-not/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 08:29:02 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=1804</guid>
		<description><![CDATA[When writting bash scripts one often needs to see if a process is running or not I like the following code; though I&#8217;m sure many ways of doing this exists, what&#8217;s your favorite? View Code BASH1 2 3 4 5 6 if &#91; -z &#34;$(pgrep process)&#34; &#93; then echo &#34;process is not running&#34; else echo &#34;process is running&#34; fi]]></description>
			<content:encoded><![CDATA[<p>When writting bash scripts one often needs to see if a process is running or not<br />
I like the following code; though I&#8217;m sure many ways of doing this exists, what&#8217;s your favorite?</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1804code4'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p18044"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p1804code4"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(pgrep process)</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
  <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;process is not running&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
     <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;process is running&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/quickly-check-if-a-process-is-running-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing all mysql tables (from all databases)</title>
		<link>http://www.sgvulcan.com/optimizing-all-mysql-tables-from-all-databases/</link>
		<comments>http://www.sgvulcan.com/optimizing-all-mysql-tables-from-all-databases/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 06:44:55 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[automatically]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[tables]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=1598</guid>
		<description><![CDATA[You want to optimize mysql tables from time to time in order to reduce fragmentation. Here&#8217;s an easy way to do it automatically (put it in a script and run it from cron for example) View Code BASH1 mysqlcheck -Aop -h hostname -u user -pPASSWORD What all those mean: &#8211;all-databases, -A; Check all tables in all databases. This is the same as using the &#8211;databases option and naming all the databases on the command line. &#8211;optimize, -o Optimize the tables. -h host to optimize (you can skip if it&#8217;s the localhost) -u mysql user -p the password]]></description>
			<content:encoded><![CDATA[<p>You want to optimize mysql tables from time to time in order to reduce fragmentation. Here&#8217;s an easy way to do it automatically (put it in a script and run it from cron for example)</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1598code6'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15986"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1598code6"><pre class="bash" style="font-family:monospace;">mysqlcheck <span style="color: #660033;">-Aop</span> <span style="color: #660033;">-h</span> <span style="color: #c20cb9; font-weight: bold;">hostname</span> <span style="color: #660033;">-u</span> user <span style="color: #660033;">-pPASSWORD</span></pre></td></tr></table></div>

<p>What all those mean:</p>
<p>&#8211;all-databases, -A; Check all tables in all databases. This is the same as using the &#8211;databases option and naming all the databases on the command line.<br />
&#8211;optimize, -o Optimize the tables.<br />
-h host to optimize (you can skip if it&#8217;s the localhost)<br />
-u mysql user<br />
-p the password</p>
<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/optimizing-all-mysql-tables-from-all-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List crontab entries for all users on a linux system</title>
		<link>http://www.sgvulcan.com/list-crontab-entries-for-all-users-on-a-linux-system/</link>
		<comments>http://www.sgvulcan.com/list-crontab-entries-for-all-users-on-a-linux-system/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 08:00:20 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[Tips and tricks]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=1155</guid>
		<description><![CDATA[This is a good one liner to remember: for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done]]></description>
			<content:encoded><![CDATA[<p>This is a good one liner to remember:</p>
<pre>for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done</pre></p>
<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/list-crontab-entries-for-all-users-on-a-linux-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force fsck on next reboot</title>
		<link>http://www.sgvulcan.com/force-fsck-on-next-reboot/</link>
		<comments>http://www.sgvulcan.com/force-fsck-on-next-reboot/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 08:07:25 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[fsck]]></category>
		<category><![CDATA[touch]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=1042</guid>
		<description><![CDATA[Let&#8217;s say you run a headless server and you want to fsck the main partition. The easy solution in this case is (if possible) to force fsck to run on the next boot. If you run slackware than all you really need is to create an empty file in /etc called forcefsck You could do this by running: View Code BASH1 touch /etc/forcefsck Other linux distributions might check for this file elsewhere, for example in the root directory so the command would be View Code BASH1 touch /forcefsck Checking the documentation will always help.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-1046" title="fsck" src="http://www.sgvulcan.com/wp-content/uploads/2010/07/fsck1-150x150.jpg" alt="fsck your main partition on the next boot" width="150" height="150" />Let&#8217;s say you run a headless server and you want to fsck the main partition. The easy solution in this case is (if possible) to force fsck to run on the next boot.</p>
<p>If you run slackware than all you really need is to create an empty file in <strong>/etc</strong> called <strong>forcefsck</strong></p>
<p>You could do this by running:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1042code9'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10429"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1042code9"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>forcefsck</pre></td></tr></table></div>

<p>Other linux distributions might check for this file elsewhere, for example in the root directory so the command would be</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1042code10'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p104210"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1042code10"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>forcefsck</pre></td></tr></table></div>

<p>Checking the documentation will always help.</p>
<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/force-fsck-on-next-reboot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wma to Mp3 a folder in one command line</title>
		<link>http://www.sgvulcan.com/wma-to-mp3-a-folder-in-one-command-line/</link>
		<comments>http://www.sgvulcan.com/wma-to-mp3-a-folder-in-one-command-line/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 16:52:51 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[Tips and tricks]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=1020</guid>
		<description><![CDATA[I have some albums that were ripped in wma form (yes a shame I know). I wanted them converted into mp3 so my collection remains consistent. So this would be a command to run in a folder filled with .wma files. This keeps the names but not the tags so be sure to use something like easytag to fill them after. View Code BASH1 for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader &#34;$i&#34; &#38;amp;&#38;amp; lame -m j -h --vbr-new -b 320 audiodump.wav -o &#34;`basename &#34;$i&#34; .wma`.mp3&#34;; done; rm -f audiodump.wav]]></description>
			<content:encoded><![CDATA[<p>I have some albums that were ripped in wma form (yes a shame I know). I wanted them converted into mp3 so my collection remains consistent.</p>
<p>So this would be a command to run in a folder filled with .wma files. This keeps the names but not the tags so be sure to use something like <a href="http://easytag.sourceforge.net/" target="_blank">easytag</a> to fill them after.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1020code12'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p102012"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1020code12"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.wma ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">mplayer</span> <span style="color: #660033;">-vo</span> null <span style="color: #660033;">-vc</span> dummy <span style="color: #660033;">-af</span> <span style="color: #007800;">resample</span>=<span style="color: #000000;">44100</span> <span style="color: #660033;">-ao</span> pcm:waveheader <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #c20cb9; font-weight: bold;">lame</span> <span style="color: #660033;">-m</span> j <span style="color: #660033;">-h</span> <span style="color: #660033;">--vbr-new</span> <span style="color: #660033;">-b</span> <span style="color: #000000;">320</span> audiodump.wav <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`basename &quot;$i&quot; .wma`</span>.mp3&quot;</span>; <span style="color: #000000; font-weight: bold;">done</span>; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> audiodump.wav</pre></td></tr></table></div>

<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/wma-to-mp3-a-folder-in-one-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily send mail from a bash script</title>
		<link>http://www.sgvulcan.com/easily-send-mail-from-a-bash-script/</link>
		<comments>http://www.sgvulcan.com/easily-send-mail-from-a-bash-script/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 14:03:51 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=747</guid>
		<description><![CDATA[Did you ever need to have e-mail's sent from within a bash script? Maybe alert you of errors encountered? Me too.

Here's an easy way on how to do it:]]></description>
			<content:encoded><![CDATA[<p>Did you ever need to have e-mail&#8217;s sent from within a bash script? Maybe alert you of errors encountered? Me too.</p>
<p>Here&#8217;s an easy way on how to do it:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p747code13'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p74713"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p747code13"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># email send script example</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># subject of email</span>
<span style="color: #007800;">SUBJECT</span>=<span style="color: #ff0000;">&quot;BASH SAYS HELLO&quot;</span>
<span style="color: #666666; font-style: italic;"># destination</span>
<span style="color: #007800;">EMAIL</span>=<span style="color: #ff0000;">&quot;user@yourdomain.com&quot;</span>
<span style="color: #666666; font-style: italic;"># Email body</span>
<span style="color: #007800;">EMAILMESSAGE</span>=<span style="color: #ff0000;">&quot;/tmp/messagebody.txt&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Email sent from BASH&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$EMAILMESSAGE</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Another text line&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$EMAILMESSAGE</span>
<span style="color: #666666; font-style: italic;"># send message using /bin/mail</span>
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SUBJECT</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$EMAIL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$EMAILMESSAGE</span></pre></td></tr></table></div>

<p>Easy.</p>
<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/easily-send-mail-from-a-bash-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rename all files in a folder from upper to lower case.</title>
		<link>http://www.sgvulcan.com/rename-all-files-in-a-folder-from-upper-to-lower-case/</link>
		<comments>http://www.sgvulcan.com/rename-all-files-in-a-folder-from-upper-to-lower-case/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 10:49:35 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=717</guid>
		<description><![CDATA[Sometimes is needed to have all files in a folder in the same case. Here&#8217;s a small script to rename all files in the folder to lower case: View Code BASH1 for i in *; do mv $i `echo $i &#124; tr &#91;:upper:&#93; &#91;:lower:&#93;`; done]]></description>
			<content:encoded><![CDATA[<p>Sometimes is needed to have all files in a folder in the same case. Here&#8217;s a small script to rename all files in the folder to lower case:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p717code15'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p71715"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p717code15"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>:upper:<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>:lower:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/rename-all-files-in-a-folder-from-upper-to-lower-case/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Export a MySQL database using the command line.</title>
		<link>http://www.sgvulcan.com/export-a-mysql-database-using-the-command-line/</link>
		<comments>http://www.sgvulcan.com/export-a-mysql-database-using-the-command-line/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 07:16:55 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=708</guid>
		<description><![CDATA[Sometimes it&#8217;s easier to just drop to the command line then browse for fancy tools like phpMyAdmin. This is useful, especially for quick jobs. View Code BASH1 mysqldump -u user -ppassword your_database &#38;gt; database_backup.sql Of course you need to replace: user &#8211; mysql username password &#8211; the password your_database &#8211; the database you want to backup Adding -h host.domain.com would allow to backup a remote mysql database from YOUR shell, something like this: View Code BASH1 mysqldump -u user -h host.domain.com -ppassword your_database &#38;gt; database_backup.sql]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-711" title="logo-mysql-110x57" src="http://www.sgvulcan.com/wp-content/uploads/2010/02/logo-mysql-110x57.png" alt="" width="110" height="57" />Sometimes it&#8217;s easier to just drop to the command line then browse for fancy tools like phpMyAdmin. This is useful, especially for quick jobs.</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p708code18'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p70818"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p708code18"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-u</span> user <span style="color: #660033;">-ppassword</span> your_database <span style="color: #000000; font-weight: bold;">&amp;</span>gt; database_backup.sql</pre></td></tr></table></div>

<p>Of course you need to replace:</p>
<ul>
<li>user &#8211; mysql username</li>
<li>password &#8211; the password</li>
<li>your_database &#8211; the database you want to backup</li>
</ul>
<p>Adding -h host.domain.com would allow to backup a remote mysql database from YOUR shell, something like this:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p708code19'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p70819"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p708code19"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-u</span> user <span style="color: #660033;">-h</span> host.domain.com <span style="color: #660033;">-ppassword</span> your_database <span style="color: #000000; font-weight: bold;">&amp;</span>gt; database_backup.sql</pre></td></tr></table></div>

<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/export-a-mysql-database-using-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking directory sizes from the BASH prompt</title>
		<link>http://www.sgvulcan.com/checking-directory-sizes-from-bash-prompt/</link>
		<comments>http://www.sgvulcan.com/checking-directory-sizes-from-bash-prompt/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 20:18:16 +0000</pubDate>
		<dc:creator>silviu</dc:creator>
				<category><![CDATA[Bash scripting]]></category>
		<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[pipe]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.sgvulcan.com/?p=697</guid>
		<description><![CDATA[The command ls can be made to show directories and permission but it will not display directory sizes. Then it&#8217;s time for other commands. For example on my hosting account there is no file manager installed and evidently x and kde is missing too so, to find out directory sizes I can use the du command. It will show something like this: View Code BASH1 2 3 4 5 6 $ du -h --max-depth=1 3.2M    ./wp-admin 24M     ./wp-content 5.9M    ./wp-includes 4.0K    ./cgi-bin 44M     . BTW the command above shows a typical WordPress installation. What I used was the switch -h which provides human readable sizes for folders (like Kilo, Giga, Tera, etc.) and I also used the swithc &#8211;max-depth to tell du only to go one folder deep otherwise it will also show the sizes of every subfolder from the current one down. Should you like to have those results sorted it&#8217;s only a matter of piping the results of du into sort, like this: View Code BASH1 2 3 4 5 6 $ du -h --max-depth=1 &#124; sort -nr 44M     . 24M     ./wp-content 5.9M    ./wp-includes 4.0K    ./cgi-bin 3.2M    ./wp-admin What sort does is &#8211; surprise, sort it&#8217;s input. The [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-698" title="bash_script" src="http://www.sgvulcan.com/wp-content/uploads/2010/01/bash_script.jpg" alt="" width="150" height="54" />The command<strong> ls </strong>can be made to show directories and permission but it will not display directory sizes. Then it&#8217;s time for other commands. For example on my hosting account there is no file manager installed and evidently x and kde is missing too so, to find out directory sizes I can use the <strong>du </strong>command. It will show something like this:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p697code22'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69722"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p697code22"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-h</span> <span style="color: #660033;">--max-depth</span>=<span style="color: #000000;">1</span>
3.2M    .<span style="color: #000000; font-weight: bold;">/</span>wp-admin
24M     .<span style="color: #000000; font-weight: bold;">/</span>wp-content
5.9M    .<span style="color: #000000; font-weight: bold;">/</span>wp-includes
4.0K    .<span style="color: #000000; font-weight: bold;">/</span>cgi-bin
44M     .</pre></td></tr></table></div>

<p>BTW the command above shows a typical WordPress installation. What I used was the switch -h which provides human readable sizes for folders (like Kilo, Giga, Tera, etc.) and I also used the swithc &#8211;max-depth to tell du only to go one folder deep otherwise it will also show the sizes of every subfolder from the current one down.</p>
<p>Should you like to have those results sorted it&#8217;s only a matter of piping the results of <strong>du </strong>into <strong>sort</strong>, like this:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p697code23'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69723"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p697code23"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-h</span> <span style="color: #660033;">--max-depth</span>=<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-nr</span>
44M     .
24M     .<span style="color: #000000; font-weight: bold;">/</span>wp-content
5.9M    .<span style="color: #000000; font-weight: bold;">/</span>wp-includes
4.0K    .<span style="color: #000000; font-weight: bold;">/</span>cgi-bin
3.2M    .<span style="color: #000000; font-weight: bold;">/</span>wp-admin</pre></td></tr></table></div>

<p>What <strong>sort </strong>does is &#8211; surprise, sort it&#8217;s input. The switches used are <strong>-n</strong> to tell sort to sort by numerical values and <strong>-r</strong> to reverse the results (from big to small). Of course from here on you can pipe to text files, use even more complicated constructs but this should take care of the base.</p>
<p>If you managed to sort your folders how about sorting my wish list <img src='http://www.sgvulcan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  don&#8217;t forget to click a sponsor.</p>
<div id="in_post_ad_bottom_1" style="clear:both;margin: 5px;padding: 0px;"><p> </p>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-7825242150714747";
/* Dupa articol 468x60, created 8/19/09 */
google_ad_slot = "8916341192";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.sgvulcan.com/checking-directory-sizes-from-bash-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

