1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#!/bin/bash
if [ -z "$1" -o -z "$2" ] ; then
echo "usage: $0 <dir> {phase1 | phase2}"
exit 1
fi
dir="$1"
phase="$2"
case "$phase" in
phase1)
if [ -e "$dir" ] ; then
echo "$dir exists, remove it first"
exit 2
fi
mkdir "$dir"
echo "Hello World!" > "$dir/A.txt"
echo "Bonjour tout le monde !" > "$dir/B.txt"
;;
phase2)
if [ ! -d "$dir" ] ; then
echo "$dir does not exist or is not a directory, run phase1 first"
exit 2
fi
rm -f "$dir/A.txt"
echo "Buongiorno a tutti !" > "$dir/C.txt"
;;
*)
echo "unknown phase"
exit 2
;;
esac
|