Copy the last modified file

Say I'm in folder /c/Users/hatter/Documents/202203(WSL), I need to copy the last downloaded file to this folder:

folder=../../Downloads/; ls -tr $folder | tail -n 1 | xargs -I{} cp $folder{} .
# https://man7.org/linux/man-pages/man1/ls.1.html
-t     sort by time, newest first; see --time
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容