
find . -maxdepth 1 -type f -printf "%p\n" | sort -rn | tail -n +2 | xargs -I{} mv {} ./tmp
利用管道用find查找文件, sort排序,用tail过滤最新的文件,最后传入mv移动。
linux下的mv命令可以批量移动文件或文件夹:
批量移动文件到home目录: mv file1 file2 file3 /home/
批量移动文件夹到home目录: mv dir1/ dir2/ dir3/ /home/
批量移动相同类型的文件或文件到到home目录: mv dir* /home/
请参看 mv --help的帮助信息.
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)