How can I retrieve the absolute filename in a shell script on Mac OS X?
#!/usr/bin/env bash scriptDir="$(cd "$(dirname "$0")" && pwd -P)"
I cheat and use perl for this very thing:
#!/bin/bash dirname=`perl -e 'use Cwd "abs_path";print abs_path(shift)' $0` echo $dirname
You'd think I'd just write the entire script in perl, and often I do, but not always.