g
Glob pattern matching for file system objects (eg
*.txt
)
Returns a list of files and directories that match a glob pattern.
Output is a JSON list.
g pattern -> <stdout>
!g pattern -> <stdout>
<stdin> -> g pattern -> <stdout>
<stdin> -> !g pattern -> <stdout>
cat @{ g *.txt }
g *.txt |> filelist.json
if { g somefile.txt } then {
# file exists
}
!if { g somefile.txt } then {
# file does not exist
}
!g *.txt
f +f -> g *.html
f +f -> !g *.html
g [aeiou]*/*
Murex globbing is based on Go’s stdlib Match library
{ term }
'*' matches any sequence of non-Separator characters
'?' matches any single non-Separator character
'[' [ '^' ] { character-range } ']'
character class (must be non-empty)
c matches character c (c != '*', '?', '\\', '[')
'\\' c matches character c
c matches character c (c != '\\', '-', ']')
'\\' c matches character c
lo '-' hi matches character c for lo <= c <= hi
If you want to exclude any matches based on wildcards, rather than include them, then you can use the bang prefix. eg
» g READ*
[
"README.html"
]
» !g *
Error in `!g` (1,1): No data returned.
!g
first looks for files that match its pattern, then it reads the file list from stdin. If stdin contains contents that are not files then !g
might not handle those list items correctly. This shouldn’t be an issue with frx
in its normal mode because it is only looking for matches however when used as !g
any items that are not files will leak through.
This is its designed feature and not a bug. If you wish to remove anything that also isn’t a file then you should first pipe into either g *
, rx .*
, or f +f
and then pipe that into !g
.
The reason for this behavior is to separate this from !regexp
and !match
.
g
!g
f
: Lists or filters file system objects (eg files)match
: Match an exact value in an arrayregexp
: Regexp tools for arrays / lists of stringsrx
: Regexp pattern matching for file system objects (eg .*\\.txt
)This document was generated from builtins/core/io/g_doc.yaml.
This site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Thu Aug 15 14:38:34 UTC 2024 against commit 50ed9d650ed9d6df391240d3c2c02e623636e508dfcdad1.
Current version is 6.2.4000 which has been verified against tests cases.