mv:无法统计错误:没有此类文件或目录错误

编程入门 行业动态 更新时间:2024-10-26 01:25:43
本文介绍了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

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

Read more about it here: mywiki.wooledge/NullGlob

希望这会有所帮助!

更多推荐

mv:无法统计错误:没有此类文件或目录错误

本文发布于:2023-07-04 11:10:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023620.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   此类   文件   目录   mv

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!