Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Batch-fixing symlink targets
Posted 08-28-2010 at 07:08 PM by the dsc
Sometimes you move the folder to which lots of symlinks were pointing, or something to that effect, and you want to simply "edit" these symlinks rather than recreating them pointing the correct new location. That's how it can be done with one line:
Of course, that will work only if the files the symlinks were pointing to were all moved together to some other location, preserving the folder structure after "/whatever/is/the/old-wrong/path" on the "/correct-new/path".
find /place-where-the-null-symlinks are/ -type l | while read nullsymlink ; do wrongpath=$(readlink "$nullsymlink") ; right=$(echo "$wrongpath" | sed s'|/whatever/is/the/old-wrong/path|/correct-new/path|') ; ln -fs "$right" "$nullsymlink" ; done
Total Comments 1
Posted 12-11-2012 at 09:25 AM by kozaki