Skip to content

Instantly share code, notes, and snippets.

@chaimleib
Created October 22, 2014 04:59
Show Gist options
  • Save chaimleib/d23264893dd115b94a4b to your computer and use it in GitHub Desktop.
Save chaimleib/d23264893dd115b94a4b to your computer and use it in GitHub Desktop.
Converts path to an absolute path. If no path given, gives current directory.
!/bin/bash
## Syntax:
## abspath [path]
# Converts path to an absolute path. If no path given, gives current directory.
function abspath() {
[[ -n "$1" ]] && pushd "$1" >/dev/null
pwd
[[ -n "$1" ]] && popd >/dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment