Skip to content

Instantly share code, notes, and snippets.

@khurshid-alam
Created June 19, 2024 11:32
Show Gist options
  • Save khurshid-alam/63b9f0a5fe93a2e68af096ede9711722 to your computer and use it in GitHub Desktop.
Save khurshid-alam/63b9f0a5fe93a2e68af096ede9711722 to your computer and use it in GitHub Desktop.
Get scripot name and path from inside bash script. see https://stackoverflow.com/a/246128/10200417
#!/bin/bash
# see https://stackoverflow.com/a/246128/10200417
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
script_name=`basename $0`
# echo "called script $script_name from $script_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment