Skip to content

Instantly share code, notes, and snippets.

@jw-foss
Created October 16, 2019 05:59
Show Gist options
  • Select an option

  • Save jw-foss/7835440991f20ffe8512fe7111ce96af to your computer and use it in GitHub Desktop.

Select an option

Save jw-foss/7835440991f20ffe8512fe7111ce96af to your computer and use it in GitHub Desktop.
Get_Source_Directory.sh
#!/usr/bin/bash
# Senario
# Direcotry: /Home/uname/work/some_proj/sub_folder
# File in /Home/uname/work/some_proj
# Command would be like
# sh ../some_shell.sh
# $pwd gets the current working diretory
BASE_DIR="$(pwd)/$(dirname $BASH_SOURCE)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment