I was trying to get libetpan up and running on iOS, however there seemed to be something wrong with their setup shell script (problem explained in more detail here).. but basically I got a folder with a long list of symlinks pointing to nowhere ie
mhdriver_types.h -> ../../src/driver/implementation/mh/mhdriver_types.h
when in fact it should be
mhdriver_types.h -> ../../../src/driver/implementation/mh/mhdriver_types.h
I want to write a shell script that loops through all the symlinks, deleting each, then recreating a symlink for it to the same former destination only one subdirectory deeper.. basically doing what i did in the example to all the files..
any ideas?
inspired by anishsane's answer i got this code that works:
for name in $(find . -type l); do
tgt=`readlink "$name"`
ln -sf ../$tgt
done
尝试:
find $DIR_PATH -type l | while read x; do tgt=`readlink "$x"`; ln -sf ../$tgt $x; done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.