How to copy the top 10 most recent files from one directory to another?

前端 未结 4 559
盖世英雄少女心
盖世英雄少女心 2021-02-14 10:04

Al my html files reside here :

/home/thinkcode/myfiles/html/

I want to move the newest 10 files to /home/thinkcode/Test

I

4条回答
  •  情书的邮戳
    2021-02-14 10:59

    cp seems to understand back-ticked commands. So you could use a command like this one to copy the 10 latest files to another folder like e.g. /test:

    cp `ls -t *.htm | head -10` /test
    

提交回复
热议问题