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

你可能感兴趣的:(Copy the last modified file)