简体   繁体   中英

how to scp multiple files from multiple directories, while different files in different directories may have the same name

I want to scp several files from remote to local, the files in remote is like this:
/data/1792348/a.stat
/data/1792348/b.stat
/data/187657/a.stat
/data/187657/b.stat
... ...

1792348 187657 etc, the middle directory name is random.

how can i scp all the files ends with .stat from remote to local?
if i tried scp -P36000 user@host:/data/ /*.stat .*, i can only get 2 files a.stat b.stat .

why i can's submit this question?
i really don't know how to solve this, and hadn't search a answer from google.

i would use rsync (which uses scp internally; but is way more elaborate, eg it will only transmit minimal changesets of data, so if you run it several times, you will get an impressive speedup)

rsync -avz /data/ \
   --include "*/" --include "*.stat" --exclude "*" \
   user@host:/path/to/dest/data/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM