I have a file called diff.txt. I Want to check whether it is empty.
I wrote a bash script something like below, but I couldn\'t get it work.
[[ -s file ]] --> Checks if file has size greater than 0
if [[ -s diff.txt ]]; then echo "file has something"; else echo "file is empty"; fi
If needed, this checks all the *.txt files in the current directory; and reports all the empty file:
for file in *.txt; do if [[ ! -s $file ]]; then echo $file; fi; done