Created
July 29, 2024 13:37
-
-
Save Georgy5/72a97ca62e30e8accfc2eb20396d0a1a to your computer and use it in GitHub Desktop.
Resolving full path to a shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Full path to this script | |
# two different ways to get the same full path | |
SCRIPT_DIR=$(dirname $(readlink -f $0)) | |
REALPATH=$(dirname $(realpath $0)) | |
echo "This script is located in: $SCRIPT_DIR" | |
echo "This script realpath is located in: $REALPATH" | |
# example use case: | |
# sudo cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/conf.d/rails_app.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment