[英]finding all subfolder with certain name such that superfolder has certain pattern
hi all I have a folder that has folders with lots of different names. 大家好我有一个文件夹,其中包含许多不同名称的文件夹。 However I want to find all the folder that start with RUN
and have a subfolder of complete
. 但是我想找到所有以RUN
开头并且子文件夹complete
的文件夹。 How can I do such a thing in terminal? 我怎么能在终端做这样的事情?
As Mac OS X is UNIX based you can use many terminal programs found on Linux etc. too. 由于Mac OS X是基于UNIX的,因此您也可以使用Linux等上的许多终端程序。 Therefore this question is not necessarily OS X related. 因此,这个问题不一定与OS X有关。
Using find
you can get all your RUN
folders with a complete
folder in it: 使用find
您可以获得包含complete
文件夹的所有RUN
文件夹:
find path_to_your_folder/Run*/complete -maxdepth 0
This gives you a list like 这给你一个像这样的列表
path_to_your_folder/Run3221/complete
path_to_your_folder/Run3289/complete
With ´sed´ you can extract from this the individual folder names: 使用'had',您可以从中提取单个文件夹名称:
find test/Run*/complete -maxdepth 0 | sed 's/.*\(Run[0-9]*\).*/\1/'
which gives you a list like you're looking for: 它给你一个像你正在寻找的列表:
Run3221
Run3289
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.