如何ls - 在osx上签名

问题描述 投票:9回答:3

我正在尝试在OSX上执行以下操作:

ls -lR --ignore *.app

这样我就可以递归搜索除.app文件夹之外的所有文件夹。

然而似乎在达尔文似乎没有--ignore--hide选项。

也许是一个脚本以递归方式搜索一个给定集合的文件夹,我不确定由于输出的格式,我无法通过任何东西管道ls -lR

./ROOT/Applications/Some_app:
drwxr-xr-x   3 admin  root  102 26 Jun 11:03 app-bundle.app  #<- WANT THIS
drwxr-xr-x@ 24 admin  root  816 26 Jun 11:24 folder          #<- WANT THIS

./ROOT/Applications/Some_app/app-bundle.app:                 #<- DON'T WANT
drwxr-xr-x  7 admin  root  238 26 Jun 11:03 Contents         #<- DON'T WANT
...
macos bash ls
3个回答
8
投票

使用find

find . -ls -name '*.app' -prune

4
投票

在bash中,您可以使用扩展globbing来排除模式。

shopt -s extglob # this must be on its own line
echo !(*.app) # match everything except for the given pattern

如果你有bash版本4或更高版本,你可以使用globstar递归执行此操作。

shopt -s globstar
shopt -s extglob 
echo **/!(*.app) 

0
投票

另一种方法是管道grep:

ls |抓住-v

© www.soinside.com 2019 - 2024. All rights reserved.