Created
October 24, 2016 17:06
-
-
Save Miciah/4207efa653fe677031062229d7d3dd6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
for fn | |
do | |
declare -A seen | |
while [[ -h "$fn" ]] | |
do | |
if [[ -n "${seen[$fn]}" ]] | |
then | |
printf 'Cycle detected; terminating.\n' | |
break | |
else | |
seen[$fn]=1 | |
if [[ -h "$fn" ]] | |
then | |
target="$(readlink "$fn")" | |
printf '%s -> %s\n' "$fn" "$target" | |
fn="$target" | |
fi | |
fi | |
done | |
if ! [[ -e "$fn" ]] | |
then | |
printf '%s does not exist.\n' "$fn" | |
else | |
ls -ld "$fn" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment