删除目录结构,但保留目录内容(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++; doneNow 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_*/.*.
更多推荐
发布评论