Skip to content

Instantly share code, notes, and snippets.

@mojaveazure
Created September 29, 2015 17:27
Show Gist options
  • Save mojaveazure/3687d0c8323f67788cee to your computer and use it in GitHub Desktop.
Save mojaveazure/3687d0c8323f67788cee to your computer and use it in GitHub Desktop.
A function that checks the extension of a file
#!/bin/bash
# A function that checks the extension of a file
function checkExtension() {
FILE="$1"
EXTENSION="$2"
if [[ "${FILE: -4}" == "${EXTENSION}" ]]
then
echo yes
return 0
else
echo no
return 1
fi
}
export -f checkExtension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment