<?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>shell &#8211; Kodono</title>
	<atom:link href="https://blog.kodono.info/wordpress/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.kodono.info/wordpress</link>
	<description>Pour tous les technophiles</description>
	<lastBuildDate>Mon, 08 Aug 2011 16:21:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>
	<item>
		<title>Retour à la ligne pour une commande shell [linux]</title>
		<link>https://blog.kodono.info/wordpress/2010/09/17/retour-a-la-ligne-pour-une-commande-shell-linux/</link>
					<comments>https://blog.kodono.info/wordpress/2010/09/17/retour-a-la-ligne-pour-une-commande-shell-linux/#respond</comments>
		
		<dc:creator><![CDATA[Aymeric]]></dc:creator>
		<pubDate>Fri, 17 Sep 2010 16:20:49 +0000</pubDate>
				<category><![CDATA[Astuce]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Niveau intermédiaire]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[shell]]></category>
		<guid isPermaLink="false">http://blog.kodono.info/wordpress/?p=490</guid>

					<description><![CDATA[[niveau intermédiaire] Difficile de trouver un titre correspondant à la problématique. Il se trouve que lorsque vous tapez la commande suivante dans un shell, vous obtenez le résultat ci-dessous: debian:~/tmp# ls test1.txt test deux.txt test_trois.txt debian:~/tmp# for i in $(find . -name &#8220;*.txt&#8221;); do echo $i; done ./test1.txt ./test_trois.txt ./test deux.txt Comme on peut le [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[niveau intermédiaire]</p>
<p>Difficile de trouver un titre correspondant à la problématique.<br />
Il se trouve que lorsque vous tapez la commande suivante dans un shell, vous obtenez le résultat ci-dessous:</p>
<div class="code">debian:~/tmp# ls<br />
test1.txt  test deux.txt  test_trois.txt<br />
debian:~/tmp# for i in $(find . -name &#8220;*.txt&#8221;); do echo $i; done<br />
./test1.txt<br />
./test_trois.txt<br />
./test<br />
deux.txt
</div>
<p>Comme on peut le constater, &#8220;test deux.txt&#8221; ayant un espace dans son nom, il est affiché sur deux lignes dans notre résultat au lieu d&#8217;une seule ligne.</p>
<p>Pour fixer ce problème, il suffit de modifier la <a href="http://tldp.org/LDP/abs/html/internalvariables.html#IFS">variable IFS</a> qui détermine le séparateur, puisque par défaut le séparateur va être un espace.<br />
Pour se faire nous devons mettre notre commande dans un script :</p>
<div class="code">#!/bin/bash<br />
# on demande à ce que le séparateur soit sur le retour à la ligne<br />
IFS=&#8217;<br />
&#8216;<br />
for i in $(find . -name &#8220;*.txt&#8221;); do<br />
  echo $i;<br />
done</div class="code">
<p>Le résultat de l&#8217;exécution de notre script :</p>
<div class="code">debian:~/tmp# ./script.sh<br />
./test1.txt<br />
./test_trois.txt<br />
./test deux.txt</div>
<p>Plus d&#8217;informations sur <a href="http://tldp.org/LDP/abs/html/internalvariables.html#IFS">http://tldp.org/LDP/abs/html/internalvariables.html#IFS</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.kodono.info/wordpress/2010/09/17/retour-a-la-ligne-pour-une-commande-shell-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
