From bb5c734d7445097e94c4a602f5ce066a836dbead Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Tue, 6 May 2025 17:51:09 +0200 Subject: vault backup: 2025-05-06 17:51:09 --- Globbing patterns.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Globbing patterns.md (limited to 'Globbing patterns.md') diff --git a/Globbing patterns.md b/Globbing patterns.md new file mode 100644 index 0000000..12b7582 --- /dev/null +++ b/Globbing patterns.md @@ -0,0 +1,24 @@ +--- +tags: + - linux +--- +https://linux.die.net/man/7/glob + +**Wildcards** +- \*: any str, including empty +- ?: any single char + +**Character classes** are wrapped with []. First char can't be ! and it can't be empty. Thus to match [ ] and ! we need to wrap them like so `[][!]` + +**Ranges** two chars separated by `-`. + +**Complementation** `[!..]` match any chars not in the character class. + +**Pathnames** globbing applies to component seperately. `/` not allowed in character classes. Wildcards don't match `/`. +Dot files must be explicitly matched, thus `*` will not match it. + +**Empty lists** A wildcard can expand into an empty list (e.g `*.gif` where no .gif exist). If the wildcard expands to an empty list or is invalid it will remain unchanged per POSIX specifications. +In bash `shopt -s nullglob` enables expanding into an empty list. + +### Difference with Regular Expressions +With globbing we match filenames rather than text. \ No newline at end of file -- cgit v1.2.3