Last active
November 4, 2016 08:45
-
-
Save cpelley/34a79c67c92fd978c774f7437284f3e5 to your computer and use it in GitHub Desktop.
Commandline utility to split the extension from the given file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Function to return the extension of a file | |
| # Returning the extension as a string (e.g. ".txt") or false otherwise. | |
| # | |
| # Add this file to your PATH to make available and ensure that it has | |
| # executable privileges. | |
| # | |
| # Example usage: | |
| # splitext <file> | |
| [[ "${1}" = *.* ]] && echo ".${1##*.}" || false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment