将文件移动到目录 [英] Moving files to a directory

查看:109
本文介绍了将文件移动到目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将当前目录中符合特定模式的所有文件移动到另一个目录.

I want to move all files matching a certain pattern in the current directory to another directory.

例如,如何将所有以nz开头的文件移动到名为foobar的目录中?我尝试使用mv来实现,但是效果不佳.

For example, how would I move all the files starting with nz to a directory called foobar? I tried using mv for that, but it didn't work out well.

推荐答案

find . | grep "your_pattern" | xargs mv destination_directory

执行以下操作:

  • 查找当前目录中的所有文件
  • 根据您的模式过滤它们
  • 将所有生成的文件移动到目标目录

这篇关于将文件移动到目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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