The following code will check if the file described by variable FILENAME
exists and has data.
if [ ! -f "$FILENAME" ]; then echo "Error: '$FILENAME' file not found."; else if [ ! -s "$FILENAME" ]; then echo "Error: '$FILENAME' file is empty."; else echo "Info: '$FILENAME' file found and contains data."; fi fi
This post is also available in: Αγγλικα