Linux: Reverse Sort files in directory and get second file
<p>I am trying to get the second file, when file contents sorted in reverse (desc order) and copy it to my local directory using <code>scp</code></p>

<p>Here's what I got:</p>

<pre><code>scp -r uname@host:./backups/dir1/$(ls -r | head -2| tail -1) /tmp/data_sync/dir1/
</code></pre>

<p>I still seem to copy all the files when I run this script. What am I missing? TIA. </p>