删除目录结构,但保留目录内容(Remove directory structure, but keep directory contents)

编程入门 行业动态 更新时间:2024-10-23 14:33:30
删除目录结构,但保留目录内容(Remove directory structure, but keep directory contents)

我的意思是在我的主目录内的特定目录中运行这段代码,但是不小心将它运行在我的主目录本身中:

i=0; for f in *; do d=dir_$(printf %03d $((i/8+1))); mkdir -p $d; mv "$f" $d; let i++; done

现在我所有的文件和目录都被分组到不同的目录中。 我需要删除此操作,并恢复我的原始组织。 这可能吗?

I meant to run this code inside a specific directory within my home directory, but accidentally ran it in my home directory itself:

i=0; for f in *; do d=dir_$(printf %03d $((i/8+1))); mkdir -p $d; mv "$f" $d; let i++; done

Now all my files and directories have been grouped into separate directories. I need to remove this action, and restore my original organization. Is this possible?

最满意答案

使用shell扩展:

mv dir_*/* .

应该将所有dir_子目录的内容移回当前目录。 对于“隐藏”文件,如有必要,请移动dir_*/.* 。

Using shell expansion:

mv dir_*/* .

should move the content of all dir_ subdirectories back into the current one. For "hidden" files, if necessary, move dir_*/.*.

更多推荐

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

发布评论

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

>www.elefans.com

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