Shell Scripting & Automation Flashcards
7 cards from real LCA practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Shell Scripting & Automation flashcards as text
Which bash option enables strict mode by catching unset variable references?
Answer: set -u
`set -u` (or `set -o nounset`) causes the shell to treat unset variables as an error and exit.
What does `set -o pipefail` change about pipeline exit status?
Answer: The pipeline returns the exit status of the last failed command, not just the last command
Without `pipefail`, a pipeline's exit status is the last command's status; with it, any failure in the pipeline propagates.
In bash, what is a here-document used for?
Answer: Providing multi-line input to a command inline in the script
A here-document (`<< DELIMITER ... DELIMITER`) feeds multiple lines of text directly as stdin to a command without needing a separate file.
Which command schedules a one-time job to run at 3:00 AM tonight on a Linux system?
Answer: echo 'command' | at 03:00
The `at` command schedules one-time tasks; you pipe the command to `at` with a time argument.
What is the correct way to source a file named `config.sh` in the current shell?
Answer: . config.sh
The dot (`.`) command or `source` built-in reads and executes commands from the file in the current shell environment.
Which tool is best suited for parsing and transforming structured text using field separators in a shell pipeline?
Answer: awk
awk is designed for field-based text processing and supports custom field separators with the -F option.
What does `nohup script.sh &` accomplish?
Answer: Runs the script in the background, immune to hangup signals when the terminal closes
`nohup` ignores the SIGHUP signal, and `&` backgrounds the process so it continues after logout.