Copying files with certain extensions with scp

Just replace it with:

scp [email protected]:'/folder/*.{jpg,png}' .

Please note the pair of single quotes. In your case, your local shell is evaluating the expression, turning it really into:

scp [email protected]:/folder/*.jpg [email protected]:/folder/*.png .

hence the two passwords asked. In this solution, the pair of single quotes protects it from evaluation by the local shell, so it's the remote shell called by (the remote) scp which is evaluating the expression.


Better to use rsync for copying operations between servers.

 rsync -avzh user@remoteip:/path/*.jpg [email protected]:/path/*.png localserverpath

Using rsync it will asks for password only one time.

Also in rsync while transferring the file it will check in the target location if the file exists or not and also check whether content is same or not in source location and target location.

If file also exists in target location and the contents are also the same, then it won't copy that file. It will only copy the files which don't exist in the target location, so it reduces processing time.

rsync is often used as an incremental backup tool.

Tags:

Scp