Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 我只想将那些排名前60位的临时文件移到某个文件夹中_Shell - Fatal编程技术网

Shell 我只想将那些排名前60位的临时文件移到某个文件夹中

Shell 我只想将那些排名前60位的临时文件移到某个文件夹中,shell,Shell,执行此命令后,我将获得该文件夹中1000个文件中的60个文件列表,其中我只想将临时文件从前60个文件移到某个文件夹中。我试着用下面的命令,但它不起作用 du -mx --exclude='.snapshot' | sort -n -r|head -n 60 试试下面的方法 du -mx --exclude='.snapshot' | sort -n -r|head -n 60 | cp *temp /mnt/TEST/ 我不是你的文件名的样子,所以我在temp上放了一个grep。你应该根据需

执行此命令后,我将获得该文件夹中1000个文件中的60个文件列表,其中我只想将临时文件从前60个文件移到某个文件夹中。我试着用下面的命令,但它不起作用

du -mx --exclude='.snapshot' | sort -n -r|head -n 60
试试下面的方法

du -mx --exclude='.snapshot' | sort -n -r|head -n 60 | cp *temp /mnt/TEST/
我不是你的文件名的样子,所以我在
temp
上放了一个
grep
。你应该根据需要修改它。
一旦它起作用,您需要将
cp
替换为
mv

您应该将-i添加到xargs以使用{}
du -mx --exclude='.snapshot' | sort -n -r | head -n 60 | grep temp | xargs cp {} /mnt/TEST/