Expanding a bit on what Jim has already said...
Your first problem (too many arguments caused by improperly quoting your operands) can be fixed by changing:
if [ $old -eq $new ] ;
to:
if [ "$old" -eq "$new" ] ;
Your second problem (using a numeric comparison operator to compare non-numeric strings) can be fixed by changing:
if [ "$old" -eq "$new" ] ;
to:
if [ "$old" = "$new" ] ;
Your third problem (assuming that human readable file sizes will change quickly enough in five seconds when file sizes will be large enough to cause a change in the output) can be fixed by changing:
du -sh /home/andy/Downloads/myfile.iso
in two places to:
du -s /home/andy/Downloads/myfile.iso
so you will be comparing the actual file sizes in bytes (instead of possibly in tenths of kilobytes, megabytes, gigabytes, terabytes, or petabytes).
Your fourth problem (assuming that the file size will change immediately between two adjacent invocations of the above du
command at the start of your script can be fixed by moving the sleep 5
from the end of your loop to the start of your loop.
That gets us to a modified script that looks something like:
#!/bin/bash
old=$(du -s /home/andy/Downloads/myfile.iso)
while true
do
sleep 5
new=$(du -s /home/andy/Downloads/myfile.iso)
if [ "$old" = "$new" ]
then
break
fi
old=$new
xdotool getactivewindow key Ctrl
done
But, I have absolutely no idea why you want to run the command xdotool getactivewindow key Ctrl
every five seconds while the size of a seemingly unrelated file is changing and not run it at all if the file has stopped growing before your script is started???
I hope this helps. But, since I don't understand what you're trying to do, I may have misread everything you're trying to do.