如何在 Linux 中将“查找"的结果通过管道传输到 mv [英] How to pipe the results of 'find' to mv in Linux

查看:19
本文介绍了如何在 Linux 中将“查找"的结果通过管道传输到 mv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过管道将查找"(在 Linux 中)的结果移动到不同的目录?这是我目前所拥有的.

How do I pipe the results of a 'find' (in Linux) to be moved to a different directory? This is what I have so far.

find ./ -name '*article*' | mv ../backup

但它还不正确(我得到一个错误,缺少文件参数,因为我没有指定文件,因为我试图从管道中获取它)

but its not yet right (I get an error missing file argument, because I didn't specify a file, because I was trying to get it from the pipe)

推荐答案

find ./ -name '*article*' -exec mv {}  ../backup  \;

find ./ -name '*article*' | xargs -I '{}' mv {} ../backup

这篇关于如何在 Linux 中将“查找"的结果通过管道传输到 mv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆