โ† All 010-160 Flashcard Decks

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
  1. What does the `-z` test operator check in `[ -z "$var" ]`?

    Answer: Whether $var is an empty string

    `-z` returns true when the string has a length of zero.

  2. Which command substitution syntax is POSIX-compatible and preferred in modern scripts?

    Answer: $(command)

    `$(command)` is the modern, nestable form of command substitution recommended by POSIX.

  3. What value does `$#` represent in a shell script?

    Answer: The number of positional parameters passed

    `$#` expands to the count of positional parameters supplied when the script was invoked.

  4. How do you make a script file executable so it can be run as `./myscript.sh`?

    Answer: chmod +x myscript.sh

    `chmod +x` adds the execute permission bit, allowing the file to be run directly.

  5. In bash, what is the correct way to compare two integer variables `a` and `b` for equality inside `[ ]`?

    Answer: [ $a -eq $b ]

    `-eq` is the arithmetic equality operator used inside `[ ]` for numeric comparisons.

  6. Which construct runs a block of commands repeatedly as long as a condition is TRUE?

    Answer: while loop

    A `while` loop evaluates its condition before each iteration and continues as long as it is true.

  7. What happens if you use `local` to declare a variable inside a bash function?

    Answer: The variable is only visible within the function

    `local` restricts the variable's scope to the function and its children, preventing pollution of the global namespace.