Tuesday, March 19, 2019

To move the five most recent files to a subdirectory

ls -rt will show you the files most recent first.

To move the most recent five to a subdirectory:

mkdir -p recent && find -maxdepth 1 -type f -printf '%T@ %P\n' | sort -rn | cut -d' ' -f2- | head -n 5 | xargs -I{} mv {} recent

No comments:

Post a Comment