Created
July 10, 2010 05:20
-
-
Save johan/470463 to your computer and use it in GitHub Desktop.
This file contains 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
#! /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 "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment