CompTIA Linux+ XK0-006 (V8) Practice Question

You are writing a portable shell script that must run under /bin/sh on several Linux servers. The script counts the number of available security updates and stores the result in a variable named updates. If the count is not equal to 0, the script should call a notify_updates function. A fragment of the script looks like:

updates=$(dnf check-update --security 2>/dev/null | grep -vc '^$')
if [ _____ ]; then   # TODO: insert test expression
    notify_updates "$updates"
fi

Which test expression should replace the blank so the condition is satisfied only when updates is numerically not equal to 0, using the single-bracket POSIX test ([ ]) builtin?

  • $updates -ge 0

  • $updates -eq 0

  • "$updates" -ne 0

  • "$updates" != 0

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