我具有以下檔案夹結構:
example/
├── bar/
│ ├── 1
│ ├── 2
│ ├── 3
│ ├── 4
│ ├── 5.txt
│ ├── bar.mylib/
│ │ ├── 1
│ │ ├── 2
│ │ ├── 3
│ │ ├── 4
│ │ ├── 5
│ │ ├── 6
│ │ └── foo/
│ │ ├── 1
│ │ ├── 3
│ │ └── 5
│ └── foo.mylib
└── foo/
├── 1
├── 3
├── 5
└── node_modules/
├── 1
├── 2
├── 3
├── 4
└── 5
5 directories, 23 files
我想建立一个
find
该命令將列出所有檔案和目錄,但不包括特定的目錄名稱模式,而無需完全輸入這些目錄,但仍在輸出中包含目錄名稱。
預期以下輸出:
example/
example/foo/
example/foo/3
example/foo/5
example/foo/1
example/foo/node_modules/
example/bar/
example/bar/5.txt
example/bar/3
example/bar/4
example/bar/1
example/bar/bar.mylib/
example/bar/foo.mylib
example/bar/2
我尝試了以下操作:
find . -type f ! -path '*/*.photoslibrary/*' ! -path '*/node_modules/*'
這種作品,但是似乎輸入了那些被忽略的目錄.此外,它没有列出被忽略的目錄(即
example/foo/node_modules/
和
example/bar/bar.mylib/
)。
我特意不得不 路徑:一个是目錄,另一个是檔案.我想同時列出两者,但忽略目錄的內容。
如何用
.mylib
做到這一點
?
find
最新回復
- 6月前1 #
策略是修剪与您的
node_modules
匹配的所有目錄 或*.mylib
(修剪意味着不要进入其中)並print所有其他檔案。如果上述任何選項對您来說都是陌生的,請咨詢Find的規格,如果需要任何說明,請發表評論。