如何在bash中拆分目录名称以在路径中的所有目录中进行递归调用
抱歉标题令人困惑,我很难描述这个问题。
我有两个可用的值,第一个是常量,第二个可以是任意数量的文件夹级别
BASE = application/classes
FOLDERS = types/ads
基于这些值,我需要运行如下命令(按顺序):
verifyDir application/classes
verifyDir application/classes/types
verifyDir application/classes/types/ads
我也可以传递所有目录到 verifyDir
如果这样更容易的话
verifyDir application/classes application/classes/types application/classes/types/ads
这是在 makefile 中,因此使用 gmake 的函数是可以接受的。
请不要回答重组我正在做的事情的建议。解释我为什么需要这个需要很长时间。
Sorry about the confusing title, I had a hard time describing the problem.
I have two values available to me, the first one is a constant and the second one could be any number of folder levels
BASE = application/classes
FOLDERS = types/ads
Based on those, I need to run commands like the following (in that order):
verifyDir application/classes
verifyDir application/classes/types
verifyDir application/classes/types/ads
I could also just pass all the directories to verifyDir
if that's easier
verifyDir application/classes application/classes/types application/classes/types/ads
This is within a makefile, so using gmake's functions is acceptable.
Please don't answer with a suggestion to restructure what I am doing. It would take way too long to explain why I need this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不是 gmake 大师,所以我只能提出一种使用 shell 实现这一目标的方法,也许它可以帮助您在 gnu make 中实现这一目标...
I'm not a gmake master, so I can just propose a way how to achieve that using shell, may be it helps you to achieve that in gnu make...
安德鲁的建议很棒。工作中有人提出了另一种解决方案,因此我将其放在这里以供参考,因为它使用了不同的技术(IFS,它更改了默认的单词分隔符)
Andrew's suggestion is great. Somebody at work came up up with another solution so I'll put it here for reference since it uses a different technique (IFS, which changes the default word separator)
另一种解决方案,使用 GNU make 函数
Another solution, using GNU make functions