Reputation: 576
I am writing a bash script that will get files from one directory of remote host. Here, I want to get files that were modified after given time.
sftp userme@remote_host_addr:/somedirectoryonremoteserver
> mget
Here, how can I pass the timing to sftp
command to get only files whose modified time is greater than given time.
Upvotes: 1
Views: 1280
Reputation: 202282
It's rather difficult to implement this using the OpenSSH sftp
client.
You would have to:
ls -l
command;sftp
script to download (get
) the files you found.A way easier and more reliable would be to give up on the command-line sftp
. Instead, use your favorite scripting language (Python, Perl, PHP) and its native SFTP implementation.
For an example, see:
Download files from SFTP server that are older than 5 days using Python
Or use a more capable SFTP client.
Upvotes: 2