Copying Symbolic Links
Okay - well I guess I'm an idiot.. I can't find how to do this .. I have a directory with quite a few symbolic links in it, and I need to copy all the links themselves to a backup directory (not the file the links are pointing to) .. is there a way I can do a mass copy of just the links to somewhere? I've found the switch to to not follow the links, but how do I tell it to just copy symbolic links... in other words, distinguish those files from all the others?
|
for i in $1
do if [ -L $i ] then cp $1 $2 fi done |
Uhmmm Ok - forgive my stupidity - but just what do I do with that?
|
it's a script, put it in a file, make it executable and run it....
eg. ./copylinks * /tmp/links/ |
K - Did that... it ran.. copied nothing?
|
This will search for all the symlinks in a directory tree starting at the directory you are in and copy them as symlinks to a directory called /tmp/new.
Code:
find . -type l -exec cp -d {} /tmp/new \; If you want to keep the directory tree structure in tact then you could issue this command: Code:
find . -type . | cpio -pvmd /tmp/new |
no it didn't did it :D
for i in * do echo $i if [ -L "$i" ] then cp "$i" "$1" fi done there, needs to be in the same directory tho. |
All times are GMT -5. The time now is 11:32 AM. |