#!/bin/bash[[ -e $elem]]&&echo"$elem existe"# ouif[[ -e $elem]];thenecho"$elem existe"fi[[ -d $dossier]]&&echo"$dossier est un dossier"[[ -f $fichier]]&&echo"$fichier est un fichier"# negation[[ ! -e $elem]]&&echo"$elem n'existe pas"# ou[[ -e $elem]]||echo"$elem n'existe pas"for elem in *;doecho"Je parcours $elem"done# Recursif## trouver les dossiers
find . -type d
## trouver les fichiers
find . -type f
## trouver les fichiers nommés toto*
find . -type f -name "toto*"# boucle for sur find (non recommandé espace est un séparateur)for elem in $(find . -type d);doecho$elem est un dossier
done# boucle while à préférerwhileread elem;doecho$elem est un dossier
done < <(find . -type d)
Is it a Bird? Is it a Plane?? No, it's Super Poil !!!
# en vrac
Posté par M.Poil (site web personnel) . En réponse au message SCRIPT SHELL. Évalué à 2. Dernière modification le 03 janvier 2020 à 20:03.
En vrac formation accelérée
Is it a Bird? Is it a Plane?? No, it's Super Poil !!!