dimanche 4 janvier 2015

symbolic link new target


I want to change the symbolic links pointing to the current directory, to a common directory named /pool


current directory a/b common directory a/pool


I followed every I could find and came close with this script. #!/bin/sh from="$1" to="$2" shift 2 for i do a=$(readlink "$i") && ln -sf "$(echo $a | sed "s@$from@$to@")" "$i" done


before running the script ...


lrwxrwxrwx 1 neysa neysa 18 Jan 4 22:03 xfsm-logout.png -> system-log-out.png lrwxrwxrwx 1 neysa neysa 17 Jan 4 22:03 zoom-best-fit.png -> zoom-fit-best.png


after running the script ./rename-links . ../pool/ *


lrwxrwxrwx 1 neysa neysa 25 Jan 4 22:31 xfsm-logout.png -> ../pool/ystem-log-out.png lrwxrwxrwx 1 neysa neysa 24 Jan 4 22:31 zoom-best-fit.png -> ../pool/oom-fit-best.png


its working but with one fault, missing the first letter of the target. Please tell me what I am doing wrong.



Aucun commentaire:

Enregistrer un commentaire