โ† 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. In a bash `for` loop written as `for i in 1 2 3 4 5; do echo $i; done`, how many times does the loop body execute?

    Answer: 5

    The loop iterates once for each word in the list, which contains five elements.

  2. What does the `shift` command do inside a shell script?

    Answer: Shifts positional parameters left, dropping $1

    `shift` removes `$1` and renumbers remaining positional parameters so `$2` becomes `$1`, and so on.

  3. Which quoting style prevents ALL special-character interpretation in bash?

    Answer: Single quotes ''

    Single quotes preserve the literal value of every character inside them with no exceptions.

  4. What is the purpose of the `break` statement inside a loop?

    Answer: Exits the innermost loop

    `break` terminates execution of the innermost enclosing loop and resumes after it.

  5. Which variable holds all positional parameters passed to a script as a single quoted string?

    Answer: $*

    `$*` expands all positional parameters as a single word joined by the first character of IFS.

  6. What will `echo ${#name}` print if `name="Linux"`?

    Answer: 5

    The `${#var}` expansion returns the length in characters of the variable's value.

  7. In a `case` statement, which pattern acts as a catch-all (default) match?

    Answer: *)

    The `*)` pattern matches any string not matched by earlier patterns, serving as the default case.