mv:无法统计错误:没有此类文件或目录错误 [英] mv: cannot stat error : No such file or directory error

查看:129
本文介绍了mv:无法统计错误:没有此类文件或目录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将目录文件移动到另一个目录.使用以下程序时出现stat错误.

I need to move the files of a directory to another directory.I get stat error when I used the following program.

for i in dir1/*.txt_dir; do
mv $i/*.txt  dir2/`basename $i`.txt
done

错误消息

mv: cannot stat `dir1/aa7.txt_dir/*.txt': No such file or directory

推荐答案

通常,当扩展不匹配任何文件名的glob时,它保持不变.因此,您将获得如下结果:

Normally, when a glob which does not match any filenames is expanded, it remains unchanged. Thus, you get results like this:

$ rm .bakrm:无法删除" .bak":没有这样的文件或目录

$ rm .bak rm: cannot remove `.bak': No such file or directory

为避免这种情况,我们需要更改nullglob变量的默认值.

To avoid this we need to change the default value of nullglob variable.

    #BASH

    shopt -s nullglob

    for i in dir1/*.txt_dir; do
       mv $i/*.txt  dir2/'basename $i'.txt
    done

在此处了解更多信息: http://mywiki.wooledge.org/NullGlob

Read more about it here: http://mywiki.wooledge.org/NullGlob

希望这会有所帮助!

这篇关于mv:无法统计错误:没有此类文件或目录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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