<?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>Blog.hio.fr &#187; bash</title>
	<atom:link href="http://blog.hio.fr/category/dev/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hio.fr</link>
	<description></description>
	<lastBuildDate>Wed, 30 Jun 2010 09:16:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>BASH Comment tester si un repertoire existe</title>
		<link>http://blog.hio.fr/2009/08/26/bash-comment-tester-si-un-repertoire-existe/</link>
		<comments>http://blog.hio.fr/2009/08/26/bash-comment-tester-si-un-repertoire-existe/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 08:03:30 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[fichier]]></category>
		<category><![CDATA[repertoire]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=417</guid>
		<description><![CDATA[Voila un petit bout de bash pour tester l'existence d'un repertoire ou d'un fichier]]></description>
			<content:encoded><![CDATA[<p>Voila un petit bout de bash pour tester l&#8217;existence d&#8217;un repertoire ou d&#8217;un fichier</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/hio/test&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</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;<span style="color: #007800;">$dir</span> existe !&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>et en rajoutant un else ^^</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/hio/test&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</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;<span style="color: #007800;">$dir</span> existe !&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;<span style="color: #007800;">$dir</span> n'existe pas!&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>et en inversant le test on rajoute juste un &laquo;&nbsp;!&nbsp;&raquo; devant le &laquo;&nbsp;-d&nbsp;&raquo;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/hio/test&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</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;<span style="color: #007800;">$dir</span> n'existe pas!&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;<span style="color: #007800;">$dir</span> existe !&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>Voila, c&#8217;est pas tres compliquer ^^ et pour tester l&#8217;existence d&#8217;un fichier, on remplace juste le &laquo;&nbsp;-d&nbsp;&raquo; par un &laquo;&nbsp;-f&nbsp;&raquo;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/08/26/bash-comment-tester-si-un-repertoire-existe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BASH Mon petit script iptables</title>
		<link>http://blog.hio.fr/2009/07/25/bash-mon-petit-script-iptables/</link>
		<comments>http://blog.hio.fr/2009/07/25/bash-mon-petit-script-iptables/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 08:28:34 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[iptables]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=393</guid>
		<description><![CDATA[iptables.sh #!/bin/bash set -e iptables=&#34;/sbin/iptables&#34; modprobe=&#34;/sbin/modprobe&#34; allowporttcp=&#34;80 443 6667 6669&#34; allowportudp=&#34;1194&#34; allowporttcptoip=&#34;7000&#34; whitelist=&#34;82.225.**.** 81.56.**.** 81.57.**.**&#34; blacklist=&#34;74.52.74.** 213.23.175.** 81.2.210.** 60.242.109.**&#34; &#160; load &#40;&#41; &#123; #echo &#34;Loading kernel modules...&#34; #$modprobe ip_tables #$modprobe ip_conntrack #$modprobe iptable_filter #$modprobe ipt_state #echo &#34;Kernel modules loaded.&#34; &#160; echo &#34;Loading rules...&#34; $iptables -P FORWARD DROP $iptables -P INPUT DROP $iptables -N blacklist $iptables [...]]]></description>
			<content:encoded><![CDATA[<p><strong>iptables.sh</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
<span style="color: #007800;">iptables</span>=<span style="color: #ff0000;">&quot;/sbin/iptables&quot;</span>
<span style="color: #007800;">modprobe</span>=<span style="color: #ff0000;">&quot;/sbin/modprobe&quot;</span>
<span style="color: #007800;">allowporttcp</span>=<span style="color: #ff0000;">&quot;80 443 6667 6669&quot;</span>
<span style="color: #007800;">allowportudp</span>=<span style="color: #ff0000;">&quot;1194&quot;</span>
<span style="color: #007800;">allowporttcptoip</span>=<span style="color: #ff0000;">&quot;7000&quot;</span>
<span style="color: #007800;">whitelist</span>=<span style="color: #ff0000;">&quot;82.225.**.** 81.56.**.** 81.57.**.**&quot;</span>
<span style="color: #007800;">blacklist</span>=<span style="color: #ff0000;">&quot;74.52.74.** 213.23.175.** 81.2.210.** 60.242.109.**&quot;</span>
&nbsp;
load <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #666666; font-style: italic;">#echo &quot;Loading kernel modules...&quot;</span>
  <span style="color: #666666; font-style: italic;">#$modprobe ip_tables</span>
  <span style="color: #666666; font-style: italic;">#$modprobe ip_conntrack</span>
  <span style="color: #666666; font-style: italic;">#$modprobe iptable_filter</span>
  <span style="color: #666666; font-style: italic;">#$modprobe ipt_state</span>
  <span style="color: #666666; font-style: italic;">#echo &quot;Kernel modules loaded.&quot;</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Loading rules...&quot;</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-P</span> FORWARD DROP
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-P</span> INPUT DROP
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-N</span> blacklist
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> eth0 <span style="color: #660033;">-j</span> blacklist
&nbsp;
    <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$allowporttcp</span>
      <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--destination-port</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">-j</span> ACCEPT
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Allow port : <span style="color: #007800;">$i</span>/tcp&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$allowportudp</span>
      <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">-m</span> udp <span style="color: #660033;">--destination-port</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">-j</span> ACCEPT
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Allow port : <span style="color: #007800;">$i</span>/udp&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$allowporttcptoip</span>
      <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #000000; font-weight: bold;">for</span> j <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$whitelist</span>
	<span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #007800;">$iptables</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--destination-port</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">$j</span> <span style="color: #660033;">-j</span> ACCEPT
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Allow port : <span style="color: #007800;">$i</span>/tcp for <span style="color: #007800;">$j</span>&quot;</span>
      <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$blacklist</span>
      <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">$i</span> <span style="color: #660033;">-j</span> DROP <span style="color: #660033;">-A</span> blacklist
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span> blacklisted&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <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>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>net<span style="color: #000000; font-weight: bold;">/</span>ipv4<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/*/</span>rp_filter;
      <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$i</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;1 &gt; <span style="color: #007800;">$i</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> ALL <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-s</span> 127.0.0.1 <span style="color: #660033;">-j</span> ACCEPT
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rules loaded.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
blacklist <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-L</span> blacklist <span style="color: #660033;">-n</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-L</span> blacklist
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
flush <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Flushing rules...&quot;</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-F</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-X</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-F</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-X</span>
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-P</span> INPUT ACCEPT
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-P</span> FORWARD ACCEPT
    <span style="color: #007800;">$iptables</span> <span style="color: #660033;">-P</span> OUTPUT ACCEPT
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rules flushed.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    start<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	flush
	load
	<span style="color: #000000; font-weight: bold;">;;</span>
    stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	flush
	<span style="color: #000000; font-weight: bold;">;;</span>
    blacklist<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	blacklist
	<span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: start|stop|restart|blacklist.&quot;</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p><strong>Utilisation</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables.sh start<span style="color: #000000; font-weight: bold;">|</span>stop<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #000000; font-weight: bold;">|</span>blacklist</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/07/25/bash-mon-petit-script-iptables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BASH Comment convertir du flac en mp3</title>
		<link>http://blog.hio.fr/2009/06/22/bash-comment-convertir-du-flac-en-mp3/</link>
		<comments>http://blog.hio.fr/2009/06/22/bash-comment-convertir-du-flac-en-mp3/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 12:47:17 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=381</guid>
		<description><![CDATA[Voila un petit script avec rien de révolutionnaire qui permet de convertir tout un répertoire de fichier au format flac en mp3]]></description>
			<content:encoded><![CDATA[<p>Voila un petit script avec rien de révolutionnaire qui permet de convertir tout un <strong>répertoire</strong> de fichier au format <strong>flac</strong> en <strong>mp3</strong></p>
<p><strong>Les dépendances</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> id3v2 flac <span style="color: #c20cb9; font-weight: bold;">lame</span></pre></div></div>

<p><strong>Le script flac2mp3.sh</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash                                                                                                                                                                         </span>
<span style="color: #007800;">output_dir</span>=<span style="color: #ff0000;">&quot;/data/sda1/music/CONVERTING_OUTPUT/$1&quot;</span>
<span style="color: #007800;">lame_opts</span>=<span style="color: #ff0000;">&quot;--vbr-new -V 2 -b 128 -B 256&quot;</span>
<span style="color: #007800;">flac_args</span>=<span style="color: #ff0000;">&quot;--silent -cd&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output_dir</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output_dir</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;create dir: <span style="color: #007800;">$output_dir</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.flac
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">ARTIST</span>=<span style="color: #000000; font-weight: bold;">`</span>metaflac <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #660033;">--show-tag</span>=ARTIST <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>=<span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">TITLE</span>=<span style="color: #000000; font-weight: bold;">`</span>metaflac <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #660033;">--show-tag</span>=TITLE <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>=<span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">ALBUM</span>=<span style="color: #000000; font-weight: bold;">`</span>metaflac <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #660033;">--show-tag</span>=ALBUM <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>=<span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">GENRE</span>=<span style="color: #000000; font-weight: bold;">`</span>metaflac <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #660033;">--show-tag</span>=GENRE <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>=<span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">TRACKNUMBER</span>=<span style="color: #000000; font-weight: bold;">`</span>metaflac <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #660033;">--show-tag</span>=TRACKNUMBER <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>=<span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span>metaflac <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #660033;">--show-tag</span>=DATE <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>.<span style="color: #000000; font-weight: bold;">*</span>=<span style="color: #000000; font-weight: bold;">//</span>g<span style="color: #000000; font-weight: bold;">`</span>
    flac <span style="color: #007800;">$flac_args</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">lame</span> <span style="color: #007800;">$lame_opts</span> - <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output_dir</span>/<span style="color: #007800;">${file%.flac}</span>.mp3&quot;</span>
    id3v2 <span style="color: #660033;">-t</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TITLE</span>&quot;</span> <span style="color: #660033;">-T</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TRACKNUMBER</span>&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ARTIST</span>&quot;</span> <span style="color: #660033;">-A</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ALBUM</span>&quot;</span> <span style="color: #660033;">-g</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$GENRE</span>&quot;</span> <span style="color: #660033;">-y</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DATE</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output_dir</span>/<span style="color: #007800;">${file%.flac}</span>.mp3&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/06/22/bash-comment-convertir-du-flac-en-mp3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BASH Comment supprimer des repertoires vide</title>
		<link>http://blog.hio.fr/2009/06/15/bash-comment-supprimer-des-repertoires-vide/</link>
		<comments>http://blog.hio.fr/2009/06/15/bash-comment-supprimer-des-repertoires-vide/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 20:17:20 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[find]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=363</guid>
		<description><![CDATA[On question simple avec une réponse tout aussi simple, comment qu'on fais pour virer un nombre N de répertoire vide sans devoir faire un 'rm -rf' a la main pour chaque répertoire.]]></description>
			<content:encoded><![CDATA[<p>Une  question simple avec une réponse tout aussi simple, comment qu&#8217;on fais pour virer un nombre N de répertoire vide sans devoir faire un &#8216;rm -rf&#8217; a la main pour chaque répertoire.</p>
<p><strong>Le find qui sert a supprimer tous les rpertoires vide d&#8217;un repertoire</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-maxdepth</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-type</span> d <span style="color: #660033;">-empty</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'rm -rf &quot;{}&quot; &amp;&amp; echo &quot;{}&quot; deleted'</span> \;</pre></div></div>

<p><strong>Je crée des répertoires bidon pour les tests :p</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hio<span style="color: #000000; font-weight: bold;">@</span>fantasy:~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">4</span>,<span style="color: #000000;">5</span>,<span style="color: #000000;">6</span>,<span style="color: #000000;">7</span>,<span style="color: #000000;">8</span>,<span style="color: #000000;">9</span>,<span style="color: #000000;">10</span>,<span style="color: #000000;">11</span>,<span style="color: #000000;">12</span>,<span style="color: #000000;">13</span>,<span style="color: #000000;">14</span>,<span style="color: #000000;">15</span>,<span style="color: #000000;">16</span>,<span style="color: #000000;">17</span>,<span style="color: #000000;">18</span>,<span style="color: #000000;">19</span>,<span style="color: #000000;">20</span>,notemptydir<span style="color: #7a0874; font-weight: bold;">&#125;</span> 
hio<span style="color: #000000; font-weight: bold;">@</span>fantasy:~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>$ <span style="color: #7a0874; font-weight: bold;">echo</span> maisblu <span style="color: #000000; font-weight: bold;">&gt;</span> notemptydir<span style="color: #000000; font-weight: bold;">/</span>testfile
hio<span style="color: #000000; font-weight: bold;">@</span>fantasy:~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
total <span style="color: #000000;">88</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">0</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">1</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">10</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">11</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">12</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">13</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">14</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">15</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">16</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">17</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">18</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">19</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">2</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">20</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">3</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">4</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">5</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">6</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">7</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">8</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 <span style="color: #000000;">9</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 notemptydir</pre></div></div>

<p><strong>On execute le find ^^</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
hio<span style="color: #000000; font-weight: bold;">@</span>fantasy:~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>$  <span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-maxdepth</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-type</span> d <span style="color: #660033;">-empty</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'rm -rf &quot;{}&quot; &amp;&amp; echo &quot;{}&quot; deleted'</span> \;
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">10</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">14</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">15</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">17</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">19</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">7</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">13</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">20</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">18</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">11</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span> deleted
.<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9</span> deleted
hio<span style="color: #000000; font-weight: bold;">@</span>fantasy:~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span>
total <span style="color: #000000;">4</span>
drwxr-xr-x <span style="color: #000000;">2</span> hio hio <span style="color: #000000;">4096</span> <span style="color: #000000;">2009</span>-06-<span style="color: #000000;">15</span> <span style="color: #000000;">22</span>:09 notemptydir</pre></div></div>

<p>Voila rien de bien sorcier ^^</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/06/15/bash-comment-supprimer-des-repertoires-vide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BASH Comment supprimer les fichiers de backup d&#8217;emacs</title>
		<link>http://blog.hio.fr/2009/06/13/bash-comment-supprimer-fichiers-backup-emacs/</link>
		<comments>http://blog.hio.fr/2009/06/13/bash-comment-supprimer-fichiers-backup-emacs/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 22:53:38 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=131</guid>
		<description><![CDATA[Voila un script qui sert a supprimer tous les vilains fichiers de backup d'emacs.]]></description>
			<content:encoded><![CDATA[<p>Voila un script qui sert a supprimer tous les vilains fichiers de backup d&#8217;emacs.</p>
<p><strong>eclean.sh</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'#*#'</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \; <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*~'</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

<p>et une version un poil plus évoluer, ça peu qd même être bien de voir ce qu&#8217;on supprime :p</p>
<p><strong>eclean.sh</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Cleaning emacs backups files ...'</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-type</span> f <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'#*#'</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'rm -f {} &amp;&amp; echo {} deleted'</span> \; <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*~'</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'rm -f {} &amp;&amp; echo {} deleted'</span> \;</pre></div></div>

<p>ce qui donne au final</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hio<span style="color: #000000; font-weight: bold;">@</span>fantasy:~$ eclean 
Cleaning emacs backups files ...
.<span style="color: #000000; font-weight: bold;">/</span>.config<span style="color: #000000; font-weight: bold;">/</span>deluge<span style="color: #000000; font-weight: bold;">/</span>gtkui.conf~ deleted
.<span style="color: #000000; font-weight: bold;">/</span>.config<span style="color: #000000; font-weight: bold;">/</span>deluge<span style="color: #000000; font-weight: bold;">/</span>blocklist.conf~ deleted
.<span style="color: #000000; font-weight: bold;">/</span>.config<span style="color: #000000; font-weight: bold;">/</span>deluge<span style="color: #000000; font-weight: bold;">/</span>core.conf~ deleted
.<span style="color: #000000; font-weight: bold;">/</span>.emacs~ deleted
.<span style="color: #000000; font-weight: bold;">/</span>.bashrc~ deleted</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/06/13/bash-comment-supprimer-fichiers-backup-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Script bash pour dumper une db</title>
		<link>http://blog.hio.fr/2009/03/03/mysql-script-bash-pour-dumper-une-db/</link>
		<comments>http://blog.hio.fr/2009/03/03/mysql-script-bash-pour-dumper-une-db/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 21:08:27 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[dump]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=120</guid>
		<description><![CDATA[Voila un ptit script pratique pour dumper une db et la compresser ^^]]></description>
			<content:encoded><![CDATA[<p>Voila un ptit script pratique pour dumper une db et la compresser ^^</p>
<p><strong>mysqldump.sh</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">tar_args</span>=<span style="color: #ff0000;">'-czf'</span>
<span style="color: #007800;">tmpdir</span>=<span style="color: #ff0000;">'/tmp'</span>
<span style="color: #007800;">mysqldump_args</span>=<span style="color: #ff0000;">'--user=root --password=password -c'</span>
&nbsp;
mysqldump <span style="color: #007800;">$mysqldump_args</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>$1.sql
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> $<span style="color: #000000;">2</span>
    <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'output dir does not exists'</span>;
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>$1.sql
    <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #007800;">$tar_args</span> $<span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span>$1.tar.gz <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>$1.sql <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$tmpdir</span><span style="color: #000000; font-weight: bold;">/</span>$1.sql
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p><strong>Utilisation</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>mysqldump.sh wordpress <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>hio<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p><strong>Explication</strong><br />
Premier argument = nom de la db<br />
Deuxieme argument = Repertoire qui contiendra la db dans un tar.gz</p>
<p>On trouvera donc un wordpress.tar.gz dans /home/hio/</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">hio<span style="color: #000000; font-weight: bold;">@</span>phpoulpe:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>hio<span style="color: #666666; font-style: italic;"># ls -l /home/hio/wordpress.tar.gz</span>
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> hio hio <span style="color: #000000;">78423</span> mar  <span style="color: #000000;">3</span> <span style="color: #000000;">22</span>:05 <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>hio<span style="color: #000000; font-weight: bold;">/</span>wordpress.tar.gz</pre></div></div>

<p>Simple, pratique et efficace ^^</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/03/03/mysql-script-bash-pour-dumper-une-db/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
