How to copy the top 10 most recent files from one directory to another?
awk, copy, linux, ls
Solution
ls -lt *.htm | head -10 | awk '{print "cp " $9 " ../Test/"$9}' | sh
Problem
Al my html files reside here : ``` /home/thinkcode/myfiles/html/ ``` I want to move the newest 10 files to `/home/thinkcode/Test` I have this so far. Please correct me. I am looking for a one-liner! ``` ls -lt *.htm | head -10 | awk '{print "cp "$1" "..\Test\$1}' | sh ```