I'm having some trouble with iterating through my script within my subscript. The problem seems to be that one i run it, it only iterates over the first index of my $@ list. I'm thinking it stops and waits for a change before it continues to the next file. The point of my subscript is to go over multiple files at the same time using my "single file script". If i change my file, it continues to the next index but not if i let it be. I hope i made my self clear. Thank you!
Script 1:
#!/bin/bash
timestamp() {
date +"%T"
}
FILE=$1
timeer=$(stat -f "%Sm" $FILE)
myDate=$(date +%b" "%d" "%H:%M:%S" "%Y)
if [ -f $FILE ]; then
timestamp
echo "Filen{$FILE} ble opprettet"
fi
while :
do
Atimeer=$(stat -f "%Sm" $FILE)
if [[ "$Atimeer" != "$timeer" && -f $FILE ]]; then
timestamp
echo "Filen ble endret!!!"
exit 130
fi
if [ ! -f "$FILE" ]; then
echo "Filen {$FILE} ble slettet.."
exit 130
fi
done
script 2:
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Not enough arguments, Call this script with"
echo "Write: ${0} <file.name>"
exit 1
fi
while :
do
for i in "${@}"
do
echo $i
sh filkontroll.sh "$i"
done
sleep 3
done