From 334984c91e545dbdbb769e0532037f3dc1c9545f Mon Sep 17 00:00:00 2001 From: tiyn Date: Sat, 5 Aug 2023 00:19:26 +0200 Subject: [PATCH] shell: added bracket expansions --- wiki/linux/shell.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wiki/linux/shell.md b/wiki/linux/shell.md index 5d4b285..de8c958 100644 --- a/wiki/linux/shell.md +++ b/wiki/linux/shell.md @@ -24,6 +24,29 @@ The following is a list of Unix shells that are POSIX compliant. This section addresses various different functions by and actions that can be taken with shell commands. +### Expansion + +This section is based on the +[TLDP Bash guide for beginners](https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html). +Although it is centered on Bash it can also be used in other shells (Zsh) while being unsupported +by others (DASH). + +In most shells curly braces can be used to expand a term. +Commands can be expanded like the following example. + +```sh +echo sp{el,il,al}l +``` + +The previous command will expand to the following command. + +```sh +echo spell spill spall +``` + +The example shows a brace expansions of depth `1`. +Using multiple curly brace pairs the depth can be increased as needed. + ### For Loops For loops can be especially useful when scripting.