如何将前10个最新文件从一个目录复制到另一个目录? [英] How to copy the top 10 most recent files from one directory to another?
本文介绍了如何将前10个最新文件从一个目录复制到另一个目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的html文件也位于此处:
Al my html files reside here :
/home/thinkcode/myfiles/html/
我想将最新的10个文件移动到/home/thinkcode/Test
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
推荐答案
ls -lt *.htm | head -10 | awk '{print "cp " $9 " ../Test/"$9}' | sh
这篇关于如何将前10个最新文件从一个目录复制到另一个目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文