You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用单个Glob表达式匹配子目录级@c8y目录内容

Solution for Targeted Glob Matching

Got it, let's nail down that single glob expression you need. The core goal here is to only match @c8y directories that sit at least one level deep (not directly in the root), while excluding the root-level @c8y/apps and @c8y/client.

The Working Glob Expression

**/*/@c8y/**

Why This Works

Let's break it down piece by piece:

  • **: Matches any number of directories (including zero, but we pair it with * to force at least one parent folder)
  • *: Requires exactly one directory segment before @c8y—this is the critical piece that rules out root-level @c8y entries
  • @c8y/: Targets the specific subdirectory we want to match
  • **: Matches any files or nested subdirectories inside the targeted @c8y folder

Testing Against Your Paths

  • ❌ Excluded: @c8y/apps, @c8y/client (no parent directory exists before @c8y, so the * segment can't find a match)
  • ✅ Matched: project-a/@c8y/client, project-b/@c8y/client, foo/@c8y/client, and all other nested @c8y entries (each has a parent directory that the * segment captures)

Why Your Previous Attempts Failed

  • **/@c8y/**: This matches root-level @c8y directories because ** can resolve to an empty path—so it effectively becomes @c8y/** for root entries, which is exactly what you wanted to avoid.
  • {!,**/}@c8y/**: This syntax doesn't properly enforce the parent directory requirement in most glob parsers. It's not a valid way to exclude root-level matches while including nested ones.

Quick Note

This works in most modern glob implementations (like Node.js's glob package, or tools that use it such as Webpack, Rollup, etc.). If you're using a more minimal glob parser, double-check that it supports the ** wildcard for recursive matching.

内容的提问来源于stack exchange,提问作者Glenn Mohammad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:45:45