bashfileexistsβ’β’β’
The code above will check to see if the file "/dossier/fichier.txt" exists, and if it does, it will print "Mon fichier existe"β¦.If the file doesn't exist, then the code will print "Mon fichier n'existe pas".
Library: Scripting et automatismes
#!/bin/bash
MON_FICHIER="/dossier/fichier.txt"
if [ -e $MON_FICHIER ]
then
echo "Mon fichier existe"
else
echo "Mon fichier n'existe pas"
fi