Shell -- 将需要的文件搬运到指定目录下

find . -name '*.ko' | xargs mv -t output/
注:
   从当前目录开始搜索,将所有的ko文件全都搬运到output目录下

find 的作用应该不用多说吧,xargs 配合管道 (|) 的作用就是把前一条命令(find)的输出作为命令行参数来执行命令(mv -t .),整个管道命令大致相当于:

mv -t . 'find . -name '*.ko''


但是不用 xargs 时,如果 find 的结果太多,可能导致 too many arguments 的错误,有 xargs 后,xargs 会自动处理这种情况,当 find 输出太长时,xargs 自动分割成多条命令。

mv -t . files


的作用是把 files 移到当前( . )下的

猜你喜欢

转载自blog.csdn.net/Ivan804638781/article/details/106255672