【发布时间】:2019-04-09 23:58:09
【问题描述】:
我想将 Python 的一个函数应用于给定目录的子目录中的所有文件。
在 bash,.sh 文件中,我列出了所有文件,如下所示:
dir_list=()
while IFS= read -d $'\0' -r file ; do
dir_list=("${dir_list[@]}" "$file")
done < <(find give_directory_Here -mindepth 2 -maxdepth 2 -type d -print0)
但是,有一些目录具有模式,假设模式是 unwanted_pattern,我想从 dir_list 中删除它们的名称。
我该怎么做?
我在这里尝试了一些对我不起作用的东西: solution 1 from stack over flow 或者 solution 2 from stack exchange,以此类推!
【问题讨论】:
-
第一行提到了Python,但是在这里我没有看到其他关于Python的内容,意思也不清楚。如果您只是将其编辑掉,它会一样准确吗?
标签: arrays bash list command-line remove-if