Skip to content

Instantly share code, notes, and snippets.

@dsquier
Created April 11, 2014 21:10
Show Gist options
  • Save dsquier/10501904 to your computer and use it in GitHub Desktop.
Save dsquier/10501904 to your computer and use it in GitHub Desktop.
AWK function to strip a file extension
## Strip the trailing extension from a file
strip_ext() {
FILENAME=$1
EXTENSION=`echo $FILENAME | gawk -F. '{ print "."$NF }'`
echo $FILENAME | awk -F$EXTENSION '{ print $1 }'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment