|
Hi,
This works:
cp `ls -latr | grep '^-' | tail -1 | awk '{ print $NF }'` /tmp
It also takes in account the existence of none-file entries (dirs, links etc), they are ignored. 'dot' files are not ignored.
If there are only regular files present in a directory, it's simpeler:
cp `ls -1tr | tail -1` /tmp
Hope this helps.
|