<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://forum.ubuntu-fr.org/extern.php?action=feed&amp;tid=376434&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Forum Ubuntu-fr.org / [bash] annuler un déplacement/renommage de fichier]]></title>
		<link>http://forum.ubuntu-fr.org/viewtopic.php?id=376434</link>
		<description><![CDATA[Les sujets les plus récents dans [bash] annuler un déplacement/renommage de fichier.]]></description>
		<lastBuildDate>Sun, 31 Jan 2010 23:15:30 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Réponse à&#160;:  [bash] annuler un déplacement/renommage de fichier]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=3250709#p3250709</link>
			<description><![CDATA[<p>bien vu sputnick <img src="http://forum.ubuntu-fr.org/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[dummy@example.com (nesthib)]]></author>
			<pubDate>Sun, 31 Jan 2010 23:15:30 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=3250709#p3250709</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [bash] annuler un déplacement/renommage de fichier]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=3250596#p3250596</link>
			<description><![CDATA[<p>Il existe aussi cela que je trouve plus mnemonic :</p><p><strong>mv foo bar<br />mv !$ !^</strong> # equivalent à <strong>mv bar foo</strong></p>]]></description>
			<author><![CDATA[dummy@example.com (sputnick)]]></author>
			<pubDate>Sun, 31 Jan 2010 22:16:30 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=3250596#p3250596</guid>
		</item>
		<item>
			<title><![CDATA[[bash] annuler un déplacement/renommage de fichier]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=3250569#p3250569</link>
			<description><![CDATA[<p>vous venez de déplacer/renommer un fichier avec la commande <strong>mv</strong> et vous souhaitez annuler ce mouvement ? (ne fonctionne pas en cas d&#039;écrasement du fichier cible)</p><p>si la commande vient juste d&#039;être lancée :</p><div class="codebox"><pre><code>mv !:2 !:1</code></pre></div><p>si d&#039;autres commandes (sauf mv) ont été lancées entre temps</p><div class="codebox"><pre><code>mv !:mv2 !mv:1</code></pre></div><p>Ceci utilise les opérateurs de substitution d&#039;historique de bash.</p><p>Limitation : impossible de scripter les substitution d&#039;historique</p><p>une solution pour passer par une fonction :</p><div class="codebox"><pre><code>function unmv () {
        command=$(history | tac | grep -m1 &quot;^[^a-Z]*mv &quot;)
        arg1=$(sed &#039;s/^[^a-Z]*mv &quot;*\([^&quot;]*[^\&quot;]\)&quot;* &quot;*\([^&quot;]*\)&quot;*/\1/&#039; &lt;&lt;&lt;$command)
        arg2=$(sed &#039;s/^[^a-Z]*mv &quot;*\([^&quot;]*[^\&quot;]\)&quot;* &quot;*\([^&quot;]*\)&quot;*/\2/&#039; &lt;&lt;&lt;$command)
        if [ -f &quot;$arg2&quot; ]; then
                mv -i &quot;$arg2&quot; &quot;$arg1&quot;
        else
                [ &quot;${arg1}&quot; = &quot;${arg1%/*}&quot; ] &amp;&amp; arg=&quot;./&quot; || arg=&quot;${arg1%/*}&quot;
                mv -i &quot;${arg2%/}/${arg1##*/}&quot; &quot;$arg&quot;
        fi
}</code></pre></div><p>(quelques bugs, notamment avec les fichiers comportant &quot; ou \ dans le nom, si quelqu&#039;un a une meilleure solution)</p>]]></description>
			<author><![CDATA[dummy@example.com (nesthib)]]></author>
			<pubDate>Sun, 31 Jan 2010 22:06:43 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=3250569#p3250569</guid>
		</item>
	</channel>
</rss>
