#! /bin/zsh # get hfsdebug-lite at http://www.osxbook.com/software/hfsdebug/ parse-hfsdebug-path () { sed -n '/^ path /s/^.*://p' } parse-hfsdebug-prev () { sed -n '/^ ownerID /s/^.* = \([0-9]*\).*/\1/p' } parse-hfsdebug-next () { sed -n '/^ groupID /s/^.* = \([0-9]*\).*/\1/p' } hardlinks () { hfsdebug=$(whence hfsdebug-lite || whence hfsdebug) stdout=$($hfsdebug "$@") parse-hfsdebug-path <<<$stdout prev=$(parse-hfsdebug-prev <<<$stdout) next=$(parse-hfsdebug-next <<<$stdout) while [[ "$prev" != "0" ]] ; do stdout=$($hfsdebug -c $prev) parse-hfsdebug-path <<<$stdout prev=$(parse-hfsdebug-prev <<<$stdout) done while [[ "$next" != "0" ]] ; do stdout=$($hfsdebug -c $next) parse-hfsdebug-path <<<$stdout next=$(parse-hfsdebug-next <<<$stdout) done } hardlinks "$@"