Basic Scripting Concepts Flashcards
7 cards from real 010-160 practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Basic Scripting Concepts flashcards as text
What does `2>/dev/null` accomplish when appended to a command?
Answer: Discards standard error output
`2>` redirects file descriptor 2 (stderr) to `/dev/null`, silently discarding error messages.
In bash, what does the `source` command (or `.`) do when given a script path?
Answer: Executes the script in the current shell environment
`source` (or `.`) runs the script within the current shell so its variable assignments and functions persist.
Which character is used to redirect standard output AND standard error to the same file in bash?
Answer: 2>&1 combined with >
Using `> file 2>&1` first redirects stdout to the file, then redirects stderr to wherever stdout now points.
What is the purpose of double brackets `[[ ]]` compared to single brackets `[ ]` in bash?
Answer: Double brackets support regex matching and avoid word-splitting issues
`[[ ]]` is a bash keyword that adds regex matching (`=~`), avoids word-splitting, and handles empty variables more safely.
Which special variable contains the process ID of the currently running script?
Answer: $$
`$$` expands to the PID of the current shell or script, often used to create unique temporary filenames.
What does the `continue` statement do inside a bash loop?
Answer: Skips the rest of the current iteration and starts the next one
`continue` jumps back to the loop condition check, skipping the remaining commands in the current iteration.
Which syntax correctly passes the output of `date` as an argument to `echo` using command substitution?
Answer: echo $(date)
`$(command)` substitutes the command's output inline, so `echo $(date)` prints the current date.