CompTIA Linux+ XK0-006 (V8) Practice Question

A Linux administrator wants a loop in a Bash script to ignore any file whose name does not end with the extension .log and writes the following check:

if [[ $file != *.log ]]; then
    echo "Skipping $file"
fi

Which statement correctly describes what the != operator does inside the [[ … ]] test used here?

  • != performs numeric inequality inside [[ … ]]; to compare strings you should use -ne instead.

  • When used inside [[ … ]], != applies an extended regular expression to the left-hand string, so a glob like *.log would be taken literally and never match.

  • != compares two strings while ignoring case differences, so DEBUG.LOG and debug.log are considered identical unless a special option is set.

  • Inside [[ … ]], != interprets the right-hand operand as an unquoted glob pattern and is true when the left-hand string does not match that pattern.

CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot