Created
April 12, 2016 01:54
-
-
Save nascimento/1ada8fc3703fa95d3e247a663fa93221 to your computer and use it in GitHub Desktop.
Script to conver symlink to file content.
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/sh | |
| set -e | |
| for link; do | |
| test -h "$link" || continue | |
| dir=$(dirname "$link") | |
| reltarget=$(readlink "$link") | |
| case $reltarget in | |
| /*) abstarget=$reltarget;; | |
| *) abstarget=$dir/$reltarget;; | |
| esac | |
| rm -fv "$link" | |
| cp -afv "$abstarget" "$link" || { | |
| # on failure, restore the symlink | |
| rm -rfv "$link" | |
| ln -sfv "$reltarget" "$link" | |
| } | |
| done |
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
| find . -type l -depth 1 -exec ./script.sh {} + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment