N
N
Nikolay Baranenko2021-04-01 20:37:53
linux
Nikolay Baranenko, 2021-04-01 20:37:53

How to correctly copy files from sftp by mask?

A trivial task is to copy some files from sftp using a mask.

Let's say there is sftp, and it has the following folder structure:

/export/else_parse/2020_12_03_19_00/newfile-2020_12_03_19_00.txt
/export/else_parse/2020_12_02_19_00/newfile-2020_12_02_19_00.txt
/export/else_parse/2020_12_01_19_00/newfile-2020_12_01_19_00.txt
/export/else_parse/2020_12_00_19_00/newfile-2020_12_00_19_00.txt

You need to pick up only files with folders that match the mask /export/else_parse/2020_12_00*.

I found the lftp utility, implemented this option:

mkdir -p /data/ftp/2020_12_00
cd /data/ftp/2020_12_00
lftp sftp://username:[email protected]:port -e "mget  /export/else_parse/2020_12_00*/*; exit"

As a result, files by mask in the local directory /data/ftp/2020_12_00.

Are there any more elegant solutions to this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2021-04-01
@ky0

scp -r [email protected]:/export/else_parse/2020_12_00* .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question