ZSH 查找多个操作员
ZSH find with multiple operators
如果我想搜索目录或符号链接,我可以在 bash 中执行以下操作:
find . \( -type d -o -type l \) -maxdepth 1
相同的命令在 ZSH 中不起作用:
find: missing argument to `-type'
): No such file or directory
-maxdepth: No such file or directory
1: No such file or directory
所以我想还需要一些转义或类似的东西。有没有办法指定此命令,以便它在 ZSH 和 bash?
中都可以使用
这里是 ZSH 中 setopt
的输出:
alwaystoend
autocd
autopushd
nobeep
nocheckjobs
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histfindnodups
histignorealldups
histignoredups
histignorespace
histsavenodups
histverify
nohup
incappendhistory
interactive
interactivecomments
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
我的 ZSH 版本是:zsh 5.8 (x86_64-ubuntu-linux-gnu)
当然,我正在使用 Oh My Zsh。
OP 确认定义了 l
的全局别名,这改变了 find
看到的参数集,导致错误。
如果我想搜索目录或符号链接,我可以在 bash 中执行以下操作:
find . \( -type d -o -type l \) -maxdepth 1
相同的命令在 ZSH 中不起作用:
find: missing argument to `-type'
): No such file or directory
-maxdepth: No such file or directory
1: No such file or directory
所以我想还需要一些转义或类似的东西。有没有办法指定此命令,以便它在 ZSH 和 bash?
中都可以使用这里是 ZSH 中 setopt
的输出:
alwaystoend
autocd
autopushd
nobeep
nocheckjobs
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histfindnodups
histignorealldups
histignoredups
histignorespace
histsavenodups
histverify
nohup
incappendhistory
interactive
interactivecomments
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
我的 ZSH 版本是:zsh 5.8 (x86_64-ubuntu-linux-gnu)
当然,我正在使用 Oh My Zsh。
OP 确认定义了 l
的全局别名,这改变了 find
看到的参数集,导致错误。