简体   繁体   English

如何在现有文件夹树中(在每个现有文件夹中)递归创建文件夹?

[英]How to create a folder recursively in an existing tree of folders (in each existing folder)?

I'm trying to create a new folder in an existing tree with : 我正在尝试通过以下方式在现有树中创建一个新文件夹:

find /home/a/Desktop/MyCycles/DavidSilver -type d -exec sh -c '(cd {} && mkdir bin)' ';'

In Ubuntu , but I get an infinite loop of 在Ubuntu中,但是我遇到了一个无限循环

mkdir: cannot create directory ‘bin’: File exists

Which BTW is not true , since the folder doesn't exist in each of the subfolders of /home/a/Desktop/MyCycles/DavidSilver . 哪个BTW不正确,因为该文件夹在/home/a/Desktop/MyCycles/DavidSilver每个子文件夹中都不存在。

Any idea how can I fix this ? 知道我该如何解决吗?

Thanks 谢谢

Assuming GNU find(1) : 假设GNU find(1)

find /home/a/Desktop/MyCycles/DavidSilver -type d -printf '%p/bin\0' | xargs -0 mkdir

Withtout GNU find(1) , but assuming directory names don't contain newlines: 没有GNU find(1) ,但是假设目录名不包含换行符:

find /home/a/Desktop/MyCycles/DavidSilver -type d | \
    sed 's!$!/bin!' | \
    xargs mkdir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM