Opération conditionnelle sur des fichiers...
Résolu/Fermé
A voir également:
- Opération conditionnelle sur des fichiers...
- Mise en forme conditionnelle excel - Guide
- Renommer des fichiers en masse - Guide
- Wetransfer gratuit fichiers lourd - Guide
- Excel liste déroulante conditionnelle - Guide
- Explorateur de fichiers - Guide
2 réponses
zipe31
Messages postés
36402
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 422
18 mai 2011 à 11:22
18 mai 2011 à 11:22
Salut,
while read line do if [ -e "${line}" ] then echo "Le fichier existe" else echo "Le fichier n'existe pas" fi done < fichier_data
Salut zipe31
ca ne fonctionne pas : test: argument expected
ca ne fonctionne pas : test: argument expected
zipe31
Messages postés
36402
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 422
18 mai 2011 à 11:49
18 mai 2011 à 11:49
Quel système ?
Quel shell ?
Chez moi ça marche ;-\
Quel shell ?
Chez moi ça marche ;-\
$ ls -l total 16 -rw-rw-r-- 1 zipe zipe 26 2011-05-18 08:22 A -rw-rw-r-- 1 zipe zipe 26 2011-05-18 08:22 B -rw-rw-r-- 1 zipe zipe 25 2011-05-18 08:22 C -rw-rw-r-- 1 zipe zipe 10 2011-05-18 11:46 plop $ cat plop A F B D C $ while read line;do if [ -e "${line}" ]; then echo "OK";else echo "Pas bon";fi;done < plop OK Pas bon OK Pas bon OK $
ll
total 40
drwxrwxr-x 2 j0279088 EP 4096 May 18 12:31 .
drwxrwxr-x 15 j0279088 EP 16384 May 18 12:29 ..
-rw-rw-r-- 1 j0279088 EP 0 May 18 12:30 A
-rw-rw-r-- 1 j0279088 EP 0 May 18 12:30 B
-rw-rw-r-- 1 j0279088 EP 0 May 18 12:31 C
-rw-rw-r-- 1 j0279088 EP 10 May 18 12:31 plop
cat plop
A
F
B
D
C
while read line ; do if [ -e "${line}" ]; then echo "OK"; else echo "Pas Bon"; fi;done < plop
while: Expression syntax
total 40
drwxrwxr-x 2 j0279088 EP 4096 May 18 12:31 .
drwxrwxr-x 15 j0279088 EP 16384 May 18 12:29 ..
-rw-rw-r-- 1 j0279088 EP 0 May 18 12:30 A
-rw-rw-r-- 1 j0279088 EP 0 May 18 12:30 B
-rw-rw-r-- 1 j0279088 EP 0 May 18 12:31 C
-rw-rw-r-- 1 j0279088 EP 10 May 18 12:31 plop
cat plop
A
F
B
D
C
while read line ; do if [ -e "${line}" ]; then echo "OK"; else echo "Pas Bon"; fi;done < plop
while: Expression syntax
zipe31
Messages postés
36402
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 422
18 mai 2011 à 13:12
18 mai 2011 à 13:12
Pourtant "while" est bien une commande de "sh" (man sh) :
Jette un oeil à ton "man sh" au cas ou il serait différent ;-(
while list; do list; done until list; do list; done The while command continuously executes the do list as long as the last command in list returns an exit status of zero. The until command is identical to the while command, except that the test is negated; the do list is executed as long as the last command in list returns a non-zero exit status. The exit status of the while and until commands is the exit status of the last do list command executed, or zero if none was executed
Jette un oeil à ton "man sh" au cas ou il serait différent ;-(