aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-02-13 00:36:48 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-02-13 00:36:48 +0100
commitb08fc0727a7086560b9cd9217fdab5d07ffee45f (patch)
tree2b0e2532deb9baa07590aae9ee9d8f706883e4ec
parent8fdf124210ae6dfa48ece265a76c14ecde1ca78b (diff)
downloadnotes-b08fc0727a7086560b9cd9217fdab5d07ffee45f.tar.gz
notes-b08fc0727a7086560b9cd9217fdab5d07ffee45f.zip
bash: cmd grouping
-rw-r--r--src/tools/bash.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tools/bash.md b/src/tools/bash.md
index a2b7944..e12d8c0 100644
--- a/src/tools/bash.md
+++ b/src/tools/bash.md
@@ -112,6 +112,22 @@ once.
vim -d <(grep foo bar) <(grep foo moose)
```
+## Command grouping
+
+Execute commands in a group with or without subshell. Can be used to easily
+redirect stdout/stderr of all commands in the group into one file.
+```bash
+# Group commands without subshell.
+v=abc ; { v=foo; echo $v; } ; echo $v
+# foo
+# foo
+
+# Group commands with subshell.
+v=abc ; ( v=foo; echo $v; ) ; echo $v
+# foo
+# abc
+```
+
## Argument parsing with `getopts`
The `getopts` builtin uses following global variables: