Question 101 of 135 from exam XK0-004: CompTIA Linux+

Question 101 of 135 from exam XK0-004: CompTIA Linux+

Question

A user wants to list the lines of a log, adding a correlative number at the beginning of each line separated by a set of dashes from the actual message.

Which of the following scripts will complete this task? A.

#!/bin/bash
LOG="/var/log/auth. log"
nrlines=0
while read LINE
do
nrlines=$((nrlines + 1))
echo $nrlines --- ${LINE}
done < ${LOG}

B.

#!/bin/bash
LOG="/var/log/auth. log"
nrlines=0
while read LINE
do
nrlines=*Snrlines ++ 1>
echo $nrlines --- ${LINES}
done

C.

#!/bin/bash
LOG="/var/log/auth.1log'
nrlines=0
while read LINE
do
nrlines=‘expr nrlines + 1°
echo $nrlines --- ${LINE}
done < ${LOG}

D.

#!/bin/bash
LOG="/var/log/auth.1log'
nrlines=0
while read LINE
do
nrlines=$(nrlines + 1)
echo $nrlines --- ${LINE}
done < ${LOG}

Explanations

D.