Linux scp copy soft link: only copy the soft link but not the actual directory

If you want to copy the soft link itself instead of the actual file, you can use -Pthe option of the scp command. This option tells the scp command to preserve soft links instead of following them and copying the actual files. Here is an example:

scp -r -P /path/to/source user@remote:/path/to/destination

Among them, -rthe option is used to recursively copy the directory, -Pthe option is used to retain the soft link, /path/to/sourceis the path of the source file or directory, user@remote:/path/to/destinationis the target path, where useris the user name of the remote host, remoteis the IP address or host name of the remote host, and /path/to/destinationis the target path.

Note that if you -Pcopy a soft link using the option, the soft link on the target path will point to the original link's path, not the actual file's path. If you need to use actual files instead of soft links on the target system, you should use -Lthe option to follow the soft links and copy the actual files.

Guess you like

Origin blog.csdn.net/a772304419/article/details/131963479