Skip to content

Instantly share code, notes, and snippets.

@goyuninfo
Last active December 23, 2020 19:00
Show Gist options
  • Save goyuninfo/327fb920304f3905c0a320cbba84770a to your computer and use it in GitHub Desktop.
Save goyuninfo/327fb920304f3905c0a320cbba84770a to your computer and use it in GitHub Desktop.
#!/bin/bash
_file="$1"
[ $# -eq 0 ] && { echo "Usage: $0 filename"; exit 1; }
[ ! -f "$_file" ] && { echo "Error: $0 file not found."; exit 2; }
if [ -s "$_file" ]
then
echo "$_file has some data."
# do something as file has data
else
echo "$_file is empty."
# do something as file is empty
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment