summaryrefslogtreecommitdiff
path: root/Globbing patterns.md
diff options
context:
space:
mode:
authorJasper Ras <jras@hostnet.nl>2025-05-06 17:51:09 +0200
committerJasper Ras <jras@hostnet.nl>2025-05-06 17:51:09 +0200
commitbb5c734d7445097e94c4a602f5ce066a836dbead (patch)
treef7c3a85f2d2d3af62561f1ef6c3cebe90e388b36 /Globbing patterns.md
parent50626752711b563185eda78ba25c145079111d14 (diff)
vault backup: 2025-05-06 17:51:09
Diffstat (limited to 'Globbing patterns.md')
-rw-r--r--Globbing patterns.md24
1 files changed, 24 insertions, 0 deletions
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