The usage of watch
is correct, but the usage of ls
I would avoid. I would recommend the usage of stat
or du
, but this depends on what you want.
du
: If you want the space occupied on your drive
stat
: If you want the number of bytes your file contains (how many bytes can I read from the file)
Imagine working with a compressed file system, or with processing sparse files, internal fragmentation, indirect blocks ...
For both cases, the result would be:
$ watch -n 5 'stat --printf "%s\n" file'
$ watch -n 5 'du -B1 file'
Both results can actually be obtained in a single command with stat
:
$ watch -n 5 'stat --printf "%s %b %B\n" file'
The product of the last two columns is the result of du
.