Here is my script, as simple as possible:
#!/bin/bash
for file in /home/pi/watch-dir/*.torrent; do
echo "$file"
sleep 2
done
Base on this answer How to iterate over files in a directory with Bash? I believe the for-in should see /home/pi/watch-dir/*.torrent
as a list.
Inside the watch-dir
directory:
pi@raspberry:~/watch_dir $ ls -al
total 68
drwxrwx--- 2 pi pi 4096 Sep 15 18:59 .
drwxr-xr-x 12 pi pi 4096 Sep 15 19:03 ..
-rwxrwx--- 1 pi pi 19065 Sep 15 18:59 asdf.torrent
-rwxrwx--- 1 pi pi 19065 Sep 15 18:59 qwer.torrent
-rwxrwx--- 1 pi pi 19065 Sep 15 18:59 zxcv.torrent
And this is the only-one-line-output after run the scipt, I really don't know what I am doing wrong...
pi@raspberry:~ $ ./test.sh
/home/pi/watch-dir/*.torrent