Re: [linux] question manipulation shell
Tu as en tous cas, généré un flood sur la liste ;-) Comme quoi il n'y a pas que des zombies ici! Xavier -- Hint: A reload a day, keeps the TAC away . On Wed, 25 Jan 2006, Rémi Letot wrote: > On Wed, 2006-01-25 at 13:44 +0100, Rémi Letot wrote: > > On Wed, 2006-01-25 at 13:20 +0100, Xavier Mertens wrote: > > > Si je comprends bien, tes fichiers sont dans le fichier 'liste'? > > > > oui > > > > > Un fichier par ligne? > > > > oui > > > > > > > Essaye ca: > > > > > > cat liste | while read NAME > > > do > > > ma_commande "$NAME" > > > done > > > > perdu :-) > > argh, panne de cerveau, copier coller qu'a pas passé les "" autour de > $NAME, j'ai corrigé et maintenant ça marche. > > Désolé pour le bruit, j'avais essayé avec ' mais pas avec ", pourtant > c'est évident quand on a la solution... > > Merci à tous, > ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
On Wed, 2006-01-25 at 13:57 +0100, Frédéric Descamps wrote: > avec une liste de fichier semblable à celle-ci (liste.txt): > > 01impress_ht_debuter.pdf > Chandler_linux_0.6.i386.tar.gz > DOKU_OFF_V_1.pdf > Pathc+ & TM1000CI_04-01-06.zip > XYfuvSn > Zimbra Collaboration Suite Data Sheet.pdf > Zimbra Quick Start.pdf > ad-ldapsearch.txt > > la commande suivante (ATTENTION il y a vraiment un carriage return après > IFS=' : > haring tmp # OLDIFS=$IFS; IFS=' > '; for i in $(cat liste.txt); do echo "fichier [$i]"; done; IFS=$OLDIFS Ah oui ça ça marche, mais dans le mail précédent la commande n'est pas la même, on avait IFS=' > '. Maintenant ça marche effectivement. > IFS permet de changer les séparateurs des commandes, par défaut c'est > l'espace,la tablulation et le \n Bon à savoir. Je viens de trouver l'explication dans man bash. Merci, -- Rémi ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
Rémi Letot wrote: On Wed, 2006-01-25 at 13:16 +0100, Fred wrote: Rémi Letot wrote: hello, comme tout est calme et que j'ai un petit problème, je m'adresse aux experts :-) J'ai une liste de noms de fichiers auxquels je dois appliquer un traitement. J'ai réussi sans problème pour la plupart, mais certains de ces noms contiennent un espace, et là je n'y arrive pas. Quoi que je fasse, le shell exécute la commande sur chacune des parties du nom. J'ai essayé plusieurs méthodes (for i in `cat liste`, cat liste | xargs,...), mais rien n'y fait. essaie avec "${variable}" donc un truc du genre: for i in $(cat liste) ; do cat "${i}" done Je ne connaissais pas cette syntaxe, mais elle ne change rien, au suivant :-) Forcement.. apres avoir reflechi sur le probleme, c'est normal. Quand tu fais $(cat list) il cree une liste plate qu'il va fournir a la boucle for. Si tu as dans ton fichier: /path/to/mon fichier1 /path/to/mon_fichier2 Le resultat "applati" donne par cat sera: /path/to/mon fichier1 /path/to/mon_fichier2 i aura donc successivement les valeurs: "/path/to/mon" "fichier1" et "/path/to/mon_fichier2"... Pour le moment, je vois pas comment faire :] Sorry :] Fred. A+, ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
tu es certain de mettre des guillemets autour de la variable qui contient le nom du fichier? Le 25/01/06, Rémi Letot<[EMAIL PROTECTED]> a écrit : > On Wed, 2006-01-25 at 13:32 +0100, Eric Darchis wrote: > > On 1/25/06, Jérôme Fenal <[EMAIL PROTECTED]> wrote: > > A raison d'un nom de fichier par ligne : > > > > cat liste | while read f ; do mv "$f" "$f".old; done > > > > J'allais répondre: > > while read i; do echo $i; done < liste > > > > Evitons d'utiliser cat (un process + un pipe) au lieu d'une > > redirection d'entrée... > > Dans l'absolu oui, mais dans ce cas ça ne change rien, echo me donne le > bon nom, mais toute autre commande agit sur les parties de ce nom. > > J'adore les espaces dans les noms de fichiers... > > -- > Rémi > > ___ > Linux Mailing List - http://www.unixtech.be > Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux > Archives: http://www.mail-archive.com/linux@lists.unixtech.be > IRC: chat.unixtech.be:6667 - #unixtech > NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech > -- -- Thomas Silvestre ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
On Wed, 2006-01-25 at 13:44 +0100, Rémi Letot wrote: > On Wed, 2006-01-25 at 13:20 +0100, Xavier Mertens wrote: > > Si je comprends bien, tes fichiers sont dans le fichier 'liste'? > > oui > > > Un fichier par ligne? > > oui > > > > Essaye ca: > > > > cat liste | while read NAME > > do > > ma_commande "$NAME" > > done > > perdu :-) argh, panne de cerveau, copier coller qu'a pas passé les "" autour de $NAME, j'ai corrigé et maintenant ça marche. Désolé pour le bruit, j'avais essayé avec ' mais pas avec ", pourtant c'est évident quand on a la solution... Merci à tous, -- Rémi ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
avec une liste de fichier semblable à celle-ci (liste.txt): 01impress_ht_debuter.pdf Chandler_linux_0.6.i386.tar.gz DOKU_OFF_V_1.pdf Pathc+ & TM1000CI_04-01-06.zip XYfuvSn Zimbra Collaboration Suite Data Sheet.pdf Zimbra Quick Start.pdf ad-ldapsearch.txt la commande suivante (ATTENTION il y a vraiment un carriage return après IFS=' : haring tmp # OLDIFS=$IFS; IFS=' '; for i in $(cat liste.txt); do echo "fichier [$i]"; done; IFS=$OLDIFS me donne comme résultat : fichier [01impress_ht_debuter.pdf] fichier [Chandler_linux_0.6.i386.tar.gz] fichier [DOKU_OFF_V_1.pdf] fichier [Pathc+ & TM1000CI_04-01-06.zip] fichier [XYfuvSn] fichier [Zimbra Collaboration Suite Data Sheet.pdf] fichier [Zimbra Quick Start.pdf] fichier [ad-ldapsearch.txt] IFS permet de changer les séparateurs des commandes, par défaut c'est l'espace,la tablulation et le \n On Wed, 2006-01-25 at 13:49 +0100, Rémi Letot wrote: > On Wed, 2006-01-25 at 13:14 +0100, Frédéric Descamps wrote: > > voilà ce qu'il faut faire : > > > > OLDIFS=$IFS; IFS=' > '; for i in $(cat liste.txt); do echo "fichier > > [$i]"; done; IFS=$OLDIFS > > Je ne sais pas exactement ce que c'était sensé faire, mais ça n'a pas > marché. Pourrais-tu expliquer la commande ? > > A+, -- Best regards, Fred. \ / \/__ T e n d /\ Frédéric Descamps / \ Senior Linux Consultant RedHat Certified Engineer - MySQL Core & Pro Certified --- (o- Linux Rules //\ No HTML in emails V_/_ http://www.x-tend.be/~fred --- signature.asc Description: This is a digitally signed message part ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
On Wed, 2006-01-25 at 13:32 +0100, Eric Darchis wrote: > On 1/25/06, Jérôme Fenal <[EMAIL PROTECTED]> wrote: > A raison d'un nom de fichier par ligne : > > cat liste | while read f ; do mv "$f" "$f".old; done > > J'allais répondre: > while read i; do echo $i; done < liste > > Evitons d'utiliser cat (un process + un pipe) au lieu d'une > redirection d'entrée... Dans l'absolu oui, mais dans ce cas ça ne change rien, echo me donne le bon nom, mais toute autre commande agit sur les parties de ce nom. J'adore les espaces dans les noms de fichiers... -- Rémi ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
On Wed, 2006-01-25 at 13:14 +0100, Frédéric Descamps wrote: > voilà ce qu'il faut faire : > > OLDIFS=$IFS; IFS=' > '; for i in $(cat liste.txt); do echo "fichier > [$i]"; done; IFS=$OLDIFS Je ne sais pas exactement ce que c'était sensé faire, mais ça n'a pas marché. Pourrais-tu expliquer la commande ? A+, -- Rémi ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
Tu as reçu pas mal de solutions déjà. Pourrais-tu lister celles que tu as déjà essayées et si elles fonctionnes ? Si aucune ne fonctionne, pourrais-tu transcrire un exemple de ton script ? merci On Wed, 2006-01-25 at 13:44 +0100, Rémi Letot wrote: > On Wed, 2006-01-25 at 13:20 +0100, Xavier Mertens wrote: > > Si je comprends bien, tes fichiers sont dans le fichier 'liste'? > > oui > > > Un fichier par ligne? > > oui > > > > Essaye ca: > > > > cat liste | while read NAME > > do > > ma_commande "$NAME" > > done > > perdu :-) > > Même symptôme, il applique la commande sur chaque partie du nom > séparément. > > Merci, -- Best regards, Fred. \ / \/__ T e n d /\ Frédéric Descamps / \ Senior Linux Consultant RedHat Certified Engineer - MySQL Core & Pro Certified --- (o- Linux Rules //\ No HTML in emails V_/_ http://www.x-tend.be/~fred --- signature.asc Description: This is a digitally signed message part ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
On Wed, 2006-01-25 at 13:16 +0100, Fred wrote: > Rémi Letot wrote: > > >hello, > > > >comme tout est calme et que j'ai un petit problème, je m'adresse aux > >experts :-) > > > >J'ai une liste de noms de fichiers auxquels je dois appliquer un > >traitement. J'ai réussi sans problème pour la plupart, mais certains de > >ces noms contiennent un espace, et là je n'y arrive pas. Quoi que je > >fasse, le shell exécute la commande sur chacune des parties du nom. J'ai > >essayé plusieurs méthodes (for i in `cat liste`, cat liste | xargs,...), > >mais rien n'y fait. > > > > > > essaie avec "${variable}" > donc un truc du genre: for i in $(cat liste) ; do cat "${i}" done Je ne connaissais pas cette syntaxe, mais elle ne change rien, au suivant :-) A+, -- Rémi ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
On Wed, 2006-01-25 at 13:20 +0100, Xavier Mertens wrote: > Si je comprends bien, tes fichiers sont dans le fichier 'liste'? oui > Un fichier par ligne? oui > Essaye ca: > > cat liste | while read NAME > do > ma_commande "$NAME" > done perdu :-) Même symptôme, il applique la commande sur chaque partie du nom séparément. Merci, -- Rémi ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
On 1/25/06, Jérôme Fenal <[EMAIL PROTECTED]> wrote: A raison d'un nom de fichier par ligne :cat liste | while read f ; do mv "$f" "$f".old; doneJ'allais répondre:while read i; do echo $i; done < listeEvitons d'utiliser cat (un process + un pipe) au lieu d'une redirection d'entrée... Quant à xargs, on peut aussi le faire avec l'option -0 (et -n1 pour les traiter un par un)cat liste |xargs -0 -n1 echoEric. ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
Si je comprends bien, tes fichiers sont dans le fichier 'liste'? Un fichier par ligne? Essaye ca: cat liste | while read NAME do ma_commande "$NAME" done Xavier -- Veni, Vidi, ROFL -- I came, I saw, I -laughed-! On Wed, 25 Jan 2006, Rémi Letot wrote: > hello, > > comme tout est calme et que j'ai un petit problème, je m'adresse aux > experts :-) > > J'ai une liste de noms de fichiers auxquels je dois appliquer un > traitement. J'ai réussi sans problème pour la plupart, mais certains de > ces noms contiennent un espace, et là je n'y arrive pas. Quoi que je > fasse, le shell exécute la commande sur chacune des parties du nom. J'ai > essayé plusieurs méthodes (for i in `cat liste`, cat liste | xargs,...), > mais rien n'y fait. > > Au secours :-) > > Merci, > ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
Le 25/01/06, Rémi Letot<[EMAIL PROTECTED]> a écrit : > hello, > > comme tout est calme et que j'ai un petit problème, je m'adresse aux > experts :-) > > J'ai une liste de noms de fichiers auxquels je dois appliquer un > traitement. J'ai réussi sans problème pour la plupart, mais certains de > ces noms contiennent un espace, et là je n'y arrive pas. Quoi que je > fasse, le shell exécute la commande sur chacune des parties du nom. J'ai > essayé plusieurs méthodes (for i in `cat liste`, cat liste | xargs,...), > mais rien n'y fait. A raison d'un nom de fichier par ligne : cat liste | while read f ; do mv "$f" "$f".old; done -- Jérôme Fenal - jfenal AT gmail.com - http://fenal.org/ Paris.pm - http://paris.mongueurs.net/ ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
voilà ce qu'il faut faire : OLDIFS=$IFS; IFS=' > '; for i in $(cat liste.txt); do echo "fichier [$i]"; done; IFS=$OLDIFS bon amusement On Wed, 2006-01-25 at 13:05 +0100, Rémi Letot wrote: > hello, > > comme tout est calme et que j'ai un petit problème, je m'adresse aux > experts :-) > > J'ai une liste de noms de fichiers auxquels je dois appliquer un > traitement. J'ai réussi sans problème pour la plupart, mais certains de > ces noms contiennent un espace, et là je n'y arrive pas. Quoi que je > fasse, le shell exécute la commande sur chacune des parties du nom. J'ai > essayé plusieurs méthodes (for i in `cat liste`, cat liste | xargs,...), > mais rien n'y fait. > > Au secours :-) > > Merci, -- Best regards, Fred. \ / \/__ T e n d /\ Frédéric Descamps / \ Senior Linux Consultant RedHat Certified Engineer - MySQL Core & Pro Certified --- (o- Linux Rules //\ No HTML in emails V_/_ http://www.x-tend.be/~fred --- signature.asc Description: This is a digitally signed message part ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech
Re: [linux] question manipulation shell
Rémi Letot wrote: hello, comme tout est calme et que j'ai un petit problème, je m'adresse aux experts :-) J'ai une liste de noms de fichiers auxquels je dois appliquer un traitement. J'ai réussi sans problème pour la plupart, mais certains de ces noms contiennent un espace, et là je n'y arrive pas. Quoi que je fasse, le shell exécute la commande sur chacune des parties du nom. J'ai essayé plusieurs méthodes (for i in `cat liste`, cat liste | xargs,...), mais rien n'y fait. essaie avec "${variable}" donc un truc du genre: for i in $(cat liste) ; do cat "${i}" done Fred. ___ Linux Mailing List - http://www.unixtech.be Subscribe/Unsubscribe: http://lists.unixtech.be/cgi-bin/mailman/listinfo/linux Archives: http://www.mail-archive.com/linux@lists.unixtech.be IRC: chat.unixtech.be:6667 - #unixtech NNTP: news.gname.org - gmane.org.user-groups.linux.unixtech