summaryrefslogtreecommitdiff
path: root/Globbing patterns.md
diff options
context:
space:
mode:
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