Skip to content

Instantly share code, notes, and snippets.

@numberwhun
Created April 6, 2015 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numberwhun/87a42c309ca014d1a0c0 to your computer and use it in GitHub Desktop.
Save numberwhun/87a42c309ca014d1a0c0 to your computer and use it in GitHub Desktop.
Getting parts of a filename in bash
~% FILE="example.tar.gz"
~% echo "${FILE%%.*}"
example
~% echo "${FILE%.*}"
example.tar
~% echo "${FILE#*.}"
tar.gz
~% echo "${FILE##*.}"
gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment