perhaps the easiest solution, but it does not apply to spaces in file names
scp `ls -t | head -3` user@server :.
using xargs has the advantage of dealing with spaces in file names, but will do scp three times
ls -t | head -3 | xargs -i scp {} user@server :.
a loop-based solution will look like this. We use by reading here because the default delimiter for reading is a newline and not a space character like a for loop
ls -t | head -3 | while read file ; do scp $file user@server ; done
saddly, an ideal solution that executes one scp command when working with white space is eluding me at the moment.
source share