繁体   English   中英

鱼壳中富含球状的ls [GS] *? [关闭]

[英]Rich globbing `ls [G-S]*` in fish shell? [closed]

在Bash中可以

ls [G-S]*

它将列出gsGS中的所有文件。

鱼壳怎么做?

您可以使用find -iregex "./[GS].*" 鱼在这方面非常有限。

Fish当前不支持丰富的Glob语法。 当前的想法是应添加glob命令,以符合通过命令而不是魔术语法执行事务的最终目标。 参见例如https://github.com/fish-shell/fish-shell/issues/3681 解决方案是创建一个过滤结果的函数。 例如, ** glob匹配CWD内和CWD之下的所有文件和目录。 我经常只需要普通文件,而忽略.git子目录。 所以我写了这个函数:

function ff --description 'Like ** but only returns plain files.'
    # This also ignores .git directories.
    find . \( -name .git -type d -prune \) -o -type f | sed -n -e '/\/\.git$/n' -e 's/^\.\///p'
end

然后可以这样使用: grep something (ff) 您可以创建一个类似的功能,该功能使用find -name模式匹配功能或使用string match --regex过滤结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM