Get latest file only from sftp using shell script
<p>I need to get only the latest file from sftp by following their date, for example it's yyyy-mm-dd. I tried the command be low but it will get all the file that in the directory.</p>

<pre><code>latest_file = `ls -ltr | tail -1 | awk '{print $9}'`
scp -r $latest_file username@server_name:/path /my/directory
</code></pre>

<p>Is there any command to get the latest file from sftp using shell script? </p>