Commande pour tester si un fichier existe [Linux - Bash] - Linux et OS Alternatifs
Marsh Posté le 05-12-2002 à 13:52:33
| Phod a écrit a écrit  : Siouplé je vais devenir   | 
 
 
if [ -f lefichier ] 
then 
   // le fichier existe 
else  
   // le fichier existe pas 
fi
Marsh Posté le 05-12-2002 à 13:56:40
Quand j'essaye ta méthode, je me prend: 
 
bash: //: is a directory 
 
(c'est juste pour trouver à redire)
Marsh Posté le 05-12-2002 à 13:57:52
| [Albator] a écrit a écrit  : | 
 
 ![[:tapai] [:tapai]](https://forum-images.hardware.fr/images/perso/tapai.gif)
Marsh Posté le 05-12-2002 à 15:29:50
http://www.shellunix.com 
EDIT : apparemment le lien est mort.   
 
Marsh Posté le 05-12-2002 à 15:44:32
le -f marche très bien, 
 
si tu te pose plus de question sur le shell, tu peux aller jeter un oeil ici : http://quong.best.vwh.net/shellin20/. 
 
C'est bien fait et ça m'a bien aidé.
Marsh Posté le 10-05-2018 à 20:54:59
hello 
il manquerait pas un ; pour le if ? 
if [ -f lefichier ] ; 
then ... 
 
| kadreg a écrit :   | 
 
Marsh Posté le 10-05-2018 à 20:57:26
le probleme était le commentaire  
# babla et pas // blabla .... 
 
c'est bien 
|  if [ ....] ; then   | 
 
ou  
|   | 
Marsh Posté le 05-12-2002 à 13:49:37
Siouplé
 
 
je vais devenir
---------------
Signatures aux choix Votez: O - Le python c'est bon, mangez-en O - L'abus de forum rend dependant, postez avec modération