Bash Cheat Sheet/Group commands in current shell

Run a grouped list in current shell.

Section: Shell Basics

Group commands in current shell

bash
bash
{ echo start; date; echo end; }
Explanation

Braces keep variable changes in current shell when syntax is valid.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Shell Basics
Run commands in subshell
Run a grouped list in a subshell.
OpenIn sheetbashsame section
Print previous exit status
Show exit status of previous command.
OpenIn sheetbashsame section
Run command sequence
Run later commands only if earlier ones succeed.
OpenIn sheetbashsame section
Run fallback command
Run fallback command when previous command fails.
OpenIn sheetbashsame section
Pipeline commands
Send output from one command to another.
OpenIn sheetbashsame section
Enable pipefail
Make pipeline fail if any command fails.
OpenIn sheetbashsame section