You are on the right track, but I would recommend rsync
instead of scp
(both will work, rsync
just enjoys more current development than scp
). When copying multiple source files, if they are not the only files in a directory, you can use wildcards with rsync
to perform the transfer. In your case you will have to invoke rsync
twice to copy to both Dir1
and Dir3
as the destination (otherwise the destination is ambiguous -- it is the same for scp
):
rsync -uv file** user@ip:/Dir1
rsync -uv file** user@ip:/Dir3
Note: you can substitute host.domain.tld
for ip
above. Also note that wildcards with rsync
are not the same as your normal wildcards used with your shell. You normally must provide a double **
for rsync
to treat it as a wildcard.
With scp
you can use your normal shell wildcards and other brace and character expansion for the transfer which can help you narrow the files to transfer:
scp file[12] user@ip:/Dir1
scp file[12] user@ip:/Dir3
To transfer only file1
and file2
to Dir1
and Dir3
at the remote ip
.