short story is, I probably need a simple loop in bash which checks periodically whether the size of a given file has changed or not since last checked.Long story, I will be downloading a file my_file.txt using Firefox. I'd like to run a command after the download has completed. Firefox doesn't seem to provide dbus calls that I could make use of. There exist some add-ons with said feature but I need a rather reliable solution. So I thought I could run a bash script that periodically checks whether the size of my_file.txt is changing over time, or has settled. The file is a text file of size <=5mb and will be downloaded locally, so it is pretty reliable and the download should run linearly (no disconnections, server issues etc). Could you help me write such simple bash script? The frequency of probing the file really seems to be key to make the thing work effectively. Like I said, it's a text file of <=5mb but can be as small as 10kb, residing on a SSD drive.Also, maybe there are better ways to accomplish this? Like I say, I need a reliable solution that runs in Linux with minimal dependencies. Maybe a download manager? Or any file monitoring daemon? Or a filesystem API for this? Or use access time rather than size?
Check in pure bash that the download is complete
bash;files;firefox;download
If you just want to wait until the file is unchanged then something like size=0 size2=$(stat --printf=%s $filename) while [ $size != $size2 ] do   sleep 5   size=$size2   size2=$(stat --printf=%s $filename) doneIf you're able to write some C then using the inotify(7) set of calls might help; you can trigger an action on a CLOSE event.