You can use cp -H option to follow command-line symbolic links in SOURCE. If a command-line argument specifies a symbolic link, then copy the file it points to rather than the symbolic link itself. However, copy (preserving its nature) any symbolic link that is encountered via recursive traversal.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
mkdir -p mydir1/mydir11 mydir2 ## create some files and directories ln -s mydir1 mylink1 echo "one" > mydir1/myfile1 echo "two" > mydir1/mydir11/myfile11 cd mydir1 ln -s mydir11 mylink11 ## create a symbolic link mylink11 pointing to mydir11 cd .. ls -R ## check directory structure, you can use tree as well cp -RH mylink1 mydir2 ## follows command-line symbolic links in SOURCE ls -R ## check directory structure, you can use tree as well rm -r my* |