Skip to content

Instantly share code, notes, and snippets.

@thorr18
Last active June 11, 2019 01:06
Show Gist options
  • Save thorr18/71bcaf8ae1f23f9ce84eea19e2dbf6ed to your computer and use it in GitHub Desktop.
Save thorr18/71bcaf8ae1f23f9ce84eea19e2dbf6ed to your computer and use it in GitHub Desktop.
Copy with scp can be weird
SCP is kinda weird.
To copy all files in 3 levels of nested directories ending in foo.bar, such as 123foo.bar & 456foo.bar:
scp USER@SERVER:'/path/to/some\ directory/*/*/*foo.bar' ./
Notice the directory name has a space in it so we escape with a backslash.
An alternative to the escape character would be double quotes within the single quotes, around the non wild part of the source path:
scp USER@SERVER:'"/path/to/some directory"/*/*/*foo.bar' ./
The destination of ./ means local directory.
@thorr18
Copy link
Author

thorr18 commented Jun 11, 2019

SCP is kinda weird.
To copy all files in 3 levels of nested directories ending in foo.bar, such as 123foo.bar & 456foo.bar:
scp USER@SERVER:'/path/to/some\ directory/*/*/*foo.bar' ./

Notice the directory name has a space in it so we escape with a backslash.

An alternative to the escape character would be double quotes within the single quotes, around the non wild part of the source path:
scp USER@SERVER:'"/path/to/some directory"/*/*/*foo.bar' ./

The destination of ./ means local directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment