Skip to content

Instantly share code, notes, and snippets.

@shubhamagarwal92
Created August 2, 2019 22:35
Show Gist options
  • Save shubhamagarwal92/f777e748a0f0df5a39a2477410302be3 to your computer and use it in GitHub Desktop.
Save shubhamagarwal92/f777e748a0f0df5a39a2477410302be3 to your computer and use it in GitHub Desktop.
Get the file name of running bash script without extension
#!/usr/bin/env bash
export CURRENT_DIR=${PWD}
export PARENT_DIR="$(dirname "$CURRENT_DIR")"
echo "File is in: " $CURRENT_DIR
# https://stackoverflow.com/questions/192319/how-do-i-know-the-script-file-name-in-a-bash-script
export FileNameWithExt=${0##*/}
export FILE_NAME=${FileNameWithExt%.*}
echo "You are running the file: " $FILE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment