declare -i fil="$1"
declare -t tid="$2"
notFinished=true
finnes=false
if [ -f $fil ];
then
finnes = true
fi
while $notFinished;
do
if [ -f $fil && ! $finnes ]; (14)
then
echo "Filen: $fil ble opprettet."
finished=true
fi
if [ ! -f $fil && $finnes ]; (20)
then
echo "Filen: $fil ble slettet."
finished=true
fi
sleep $tid
done
I'm trying to check if a file with the name $fil gets created, or deleted during the life of the script, only checking every $tid seconds. I also want to check if the file gets changed by comparing timestamps, but i'm not really sure how to do this.. Just want to mention that this is the first time trying to program in this language.
The only error i'm getting right now is:
/home/user/bin/filkontroll.sh: line 14: [: missing `] '
/home/user/bin/filkontroll.sh: line 20: [: missing `] '
@edit: fixed notFinished and some spacing