在 Bash 中可以
ls [G-S]*
Run Code Online (Sandbox Code Playgroud)
它会列出来自g-s和的所有文件G-S。
Fish shell 中是如何完成的?
Fish 目前不支持丰富的 glob 语法。目前的想法是,glob应该添加一个命令,以符合通过命令而不是魔法语法做事的 Fish 目标。例如,请参见https://github.com/fish-shell/fish-shell/issues/3681。解决方案是创建一个过滤结果的函数。例如,**glob 匹配 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
Run Code Online (Sandbox Code Playgroud)
然后我可以这样使用:grep something (ff). 您可以创建一个使用find -name模式匹配功能的类似函数或使用 过滤结果string match --regex。
| 归档时间: |
|
| 查看次数: |
1276 次 |
| 最近记录: |