Xioth

Bash - TP1 - fichierExisteFils.sh

Jan 26th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.35 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. repCourant=$(ls)
  4. fichiers=""
  5. rep=""
  6.  
  7. for f in $repCourant
  8. do
  9.     if [ -d $f ]
  10.     then
  11.         rep=$f
  12.     else
  13.         fichiers="$fichiers $f"
  14.     fi
  15. done
  16.  
  17. if [[ "$rep" == "" ]]
  18. then
  19.     echo "Vous n'avez pas de sous-repertoire."
  20.     exit 1
  21. fi
  22.  
  23. cd $rep
  24.  
  25. for f in $fichiers
  26. do
  27.     if [ ! -e $f ]
  28.     then
  29.         echo "$f n'existe pas dans $rep"
  30.     fi
  31. done
Add Comment
Please, Sign In to add comment