Bash Script: Find Out In What Directory Script Is Stored Under Unix Or Linux
You can use the following line of code in a bash script to determine the directory in which the script is stored: SCRIPT_DIR=”$(cd “$(dirname “$0″)” && pwd)” Here’s how it works: dirname “$0” returns the directory component of the script’s file path. cd “$(dirname “$0″)” && pwd changes to the directory and prints the absolute … Read more