Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy contents from a directory and not symbolic link? [closed]

Tags:

linux

on a directory cp -rvf dir . copies the symbolic links and not actual contents. src is copied to module/hal/

. |-- comm |   `-- alchemist.c |-- module |   `-- hal |       `-- src |           `-- comm -> ../comm `-- src     `-- comm -> ../comm 
like image 340
Kamath Avatar asked May 24 '12 13:05

Kamath


People also ask

How do you copy the contents of a directory to another?

Copying Directories with cp Command To copy a directory, including all its files and subdirectories, use the -R or -r option.

Does removing symbolic link remove the file?

The symbolic link does not contain any data, but you can perform all operations on the symbolic link file. Removing a symbolic link does not delete the original file, but deleting a file makes the symlink a dangling link.

How do I copy a directory with symbolic links?

Use cp -P (capital P) to never traverse any symbolic link and copy the symbolic link instead. This can be combined with other options such as -R to copy a directory hierarchy — cp -RL traverses all symbolic links to directories, cp -RP copies all symbolic links as such.

Does cp copy symlinks?

As we know, cp copies the symbolic links (symlinks) in the source directory as symlinks to the destination directory.


1 Answers

From cp(1):

   -L, --dereference           always follow symbolic links in SOURCE 
like image 121
Fred Foo Avatar answered Sep 26 '22 00:09

Fred Foo