
[英]'testdir must be an absolute path' printed after using 'ls' command in fish shell
[英]Rich globbing `ls [G-S]*` in fish shell? [closed]
在Bash中可以
ls [G-S]*
它将列出gs
和GS
中的所有文件。
鱼壳怎么做?
您可以使用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.