To use scp
on a Linux or Unix system and avoid overwriting an existing file, you can use the -n
or --no-clobber
option. This option prevents scp
from overwriting existing files in the target directory.
Here’s an example of using scp
with the -n
option:
scp -n source_file user@target_host:target_directory
In this example, source_file
is the file you want to copy, user
is the username on the target host, target_host
is the hostname or IP address of the target system, and target_directory
is the directory on the target system where you want to copy the file.
If a file with the same name as source_file
exists in target_directory
, scp
will not overwrite it, and instead will terminate the transfer with an error message.
(Diazepam)