bash --versionUseful when checking feature support such as associative arrays or newer shell options.
Comprehensive Bash commands, shell syntax, quoting, variables, redirection, pipelines, and day-to-day scripting patterns.
Start Bash, inspect version, and open a clean shell.
bash --versionUseful when checking feature support such as associative arrays or newer shell options.
bash -lLoads login startup files such as /etc/profile and ~/.bash_profile depending on system configuration.
bash --noprofile --norcUseful for debugging startup configuration problems.
bash -lc 'echo "$SHELL" && pwd'Common in CI, Docker, and automation where you need Bash semantics for one command.
bash -n script.shGood first step before running a script in production or CI.
bash -x script.shHelps debug variable expansion and flow control problems.
Basic commands, chaining, and status codes.
echo $?A zero status means success by convention.
mkdir -p tmp && cd tmp && pwdUse && for fail-fast sequences.
grep -q needle file.txt || echo 'not found'Use || for error handling or defaults.
{ echo start; date; echo end; }Braces keep variable changes in current shell when syntax is valid.
( cd /tmp && pwd )Directory changes and variables do not leak back to parent shell.
ps aux | grep nginx | grep -v grepPipelines are foundational to shell workflows.
set -o pipefailImportant for reliable scripts; otherwise only final pipeline status is returned.
Redirect stdin, stdout, stderr, and combine streams.
echo 'hello' > out.txtUse >> to append instead of overwrite.
echo 'hello' >> out.txtUseful for logs and generated reports.
grep needle missing.txt 2> errors.logFile descriptor 2 is stderr.
command > all.log 2>&1Very common for logs and debugging shell jobs.
command > /dev/null 2>&1Useful in scripts when output is expected but unneeded.
cat <<'EOF'
line 1
$HOME is not expanded here
EOFQuoted delimiter disables parameter expansion.
grep -o '[0-9]\+' <<< 'order-123'Useful for compact one-liners and tests.
while IFS= read -r line; do echo "$line"; done < input.txtThe IFS= and -r pattern is the standard safe read loop.