using watch run 2 commands
You can quote the commands:
watch "du -h filename.txt && df -h"
And they'll be executed together.
If you want to make sure both commands execute, one of the ways is to separate them with ;
instead of &&
.
watch 'du -h filename.txt; df -h'
&&
allows the execution of second command (second operand, to the right of &&
) only if the first command executed successfully (exit status 0
). If this is intended behaviour, go with &&
.
For completeness sake...
watch 'du -h filename.txt || true && df -h'
The '|| true' part causes the first command to evaluate as true even if it fails for some reason. This will allow the next command after the && to execute no matter the output of first. This is most likely unnecessary for the scenario, just showing it to be possible.