In bash, check if the file size is changing, execute command if not
bash
Solution
You're asking bash to compare "135436688 /media/USB/km" as a number. You only want the first part of the output from `du`. Try using the `cut` command to do something like this:
FirstSize=$(du -s /media/USB/km | cut -f 1)
(I'm on cygwin, not Debian so I can't be 100% sure that's exactly what will work for you, but should get you going in the right direction.)
Problem
I want to check the file size (in bash on Debian) and if it's not increasing, perform a command. My sh script looks like that: ``` FirstSize=$(du -s /media/USB/km) echo $FirstSize sleep 5 SecondSize=$(du -s /media/USB/km) echo $SecondSize if [ "$FirstSize" -eq "$SecondSize" ] then echo "size is the same" mount -a sleep 15 pkill openRTSP else echo "size is changing" fi ``` The output I receive is: ``` 135436688 /media/USB/km 135437444 /media/USB/km ./size.sh: 8: [: Illegal number: 135436688 /media/USB/km size is changing ``` Could you suggest me what am I doing wrong?