Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash check if file empty

#!/bin/bash -e

if [ -s diff.txt ]; then
        # The file is not-empty.
        rm -f empty.txt
        touch full.txt
else
        # The file is empty.
        rm -f full.txt
        touch empty.txt
fi
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #check #file #empty
ADD COMMENT
Topic
Name
6+2 =