
目前我有這個 find 指令,可以避免降序特定目錄:
find . \! \( -name ".hg" -prune \) \! \( -name "localhost" -prune \) \! \( -name "logs" -prune \) -type f
該命令的工作方式就像我想要的那樣,但我正在尋找更簡潔的解決方案。我覺得我經常重複自己,並且必須有一種更優雅/更短的方法來完成相同的事情。
答案1
find . \( \( -name .hg -o -name localhost -o -name logs \) -prune \) -o -type f
答案2
find . -not \( -regex ".*/(.hg|localhost|logs)" -prune \) -type f