Skip to content

Bash Scripting For Automation

Master Bash Scripting For Automation with 120 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.

🎓 120 cards ⏱️ ~60 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

What is Bash?

Show ▼

Bash (Bourne Again SHell) is a Unix shell and command language written as a free software replacement for the Bourne shell (sh). It is the default login shell on most Linux distributions and macOS (until Catalina).

What file extension is conventionally used for Bash scripts?

Show ▼

.sh. While not strictly required for execution, .sh signals intent and lets tooling treat the file as a shell script.

What must the first line of an executable Bash script be?

Show ▼

A shebang line, e.g. #!/usr/bin/env bash or #!/bin/bash, which tells the kernel which interpreter to invoke.

What command makes a script file executable?

Show ▼

chmod +x script.sh (or chmod 755 script.sh).

How do you run a script located in the current directory?

Show ▼

./script.sh. The dot-slash is required because the current directory is not normally in $PATH.

What is the difference between <code>sh script.sh</code> and <code>./script.sh</code>?

Show ▼

sh explicitly invokes the sh interpreter and ignores the shebang, so Bash-specific features may break. ./script.sh honors the shebang and uses the listed interpreter.

What is a variable in Bash?

Show ▼

A named storage location for a value, assigned with NAME=value (no spaces around =) and referenced as $NAME or ${NAME}.

How do you make a variable available to child processes?

Show ▼

Export it: export VAR=value or VAR=value; export VAR. Without export, the variable is local to the current shell.

What is the difference between <code>$VAR</code> and <code>${VAR}</code>?

Show ▼

Both expand the value, but ${VAR} disambiguates boundaries, e.g. ${VAR}suffix vs the ambiguous $VARsuffix. It also enables parameter expansion features like default values and substring operations.

How do you provide a default value when expanding an unset variable?

Show ▼

${VAR:-default} substitutes default if VAR is unset or empty. ${VAR:=default} also assigns the default back to VAR.

What does <code>${VAR:?message}</code> do?

Show ▼

Prints message to stderr and exits the script with status 1 if VAR is unset or empty. Useful for required-input guards.

What are positional parameters?

Show ▼

The arguments passed to a script or function, accessed as $1, $2, ..., with $0 being the script name and $# the count of arguments.

🎓 Start studying Bash Scripting For Automation

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

Related Topics in Programming

📖 Learning Resources