Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save goyuninfo/e0275afb2385381483e86ef6a4aeec91 to your computer and use it in GitHub Desktop.
Save goyuninfo/e0275afb2385381483e86ef6a4aeec91 to your computer and use it in GitHub Desktop.
#!/bin/bash
# get file name only without path
file_name=$(basename $BASH_SOURCE)
# get extension
file_extension="${file_name##*.}"
# get file name without extension
file="${file_name%.*}"
# print them to verify
echo "Full input file : $BASH_SOURCE"
echo "Filename only : $file_name"
echo "File extension only: $file_extension"
echo "First part of filename only, without extension: $file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment