Skip to content

Instantly share code, notes, and snippets.

@keepzero
Created December 5, 2012 04:27
Show Gist options
  • Save keepzero/4212234 to your computer and use it in GitHub Desktop.
Save keepzero/4212234 to your computer and use it in GitHub Desktop.
Get absolute path of this script
#!/bin/bash
# basename - strip directory and suffix from filenames
# dirname - strip last component from file name
ABSDIR=$(cd $(dirname "$0") > /dev/null; pwd)
ABSPATH=$(cd $(dirname "$0") > /dev/null; pwd)/$(basename $0)
echo $ABSDIR
echo $ABSPATH
@keepzero
Copy link
Author

keepzero commented Dec 5, 2012

It's so ugly. But work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment