Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created January 8, 2014 21:01
Show Gist options
  • Save coderofsalvation/8324593 to your computer and use it in GitHub Desktop.
Save coderofsalvation/8324593 to your computer and use it in GitHub Desktop.
detect if arg is an empty file, returns 0 on sucess, 1 otherwise (bashfunction)
# detect if arg is an empty file, returns 0 on sucess, 1 otherwise
# @param string file
function isemptyfile()
{ [ -z "$1" ] && return 1
if [ -f "$1" ] && [ X"$(wc -c "$1" | cut -d" " -f1)" = X"0" ]; then
return 0
else
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment