Type the bash builtin command, with its argument, that reads one line from standard input and stores it in the shell variable named ANSWER.

LPIC-1 Exam 102-500, objective 105. Shells and shell scripting medium

Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.

It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.

Answer

Type the answer.

Accepted answers

Case sensitive — Linux is, and grading LS as ls would teach a falsehood.

Why

`read ANSWER` consumes one line from standard input, strips the trailing newline and assigns the result to ANSWER, without a dollar sign on the variable name. Useful options: -p to print a prompt first, -r to stop backslashes being treated as escapes (recommended, and what shellcheck advises), -s to hide typing for passwords, and -t for a timeout. With several names, the line is split on IFS and the last name receives everything that remains. read returns a non-zero exit status at end of file, which is what makes `while read -r line; do ... done < file` terminate.

Where this comes from

Cited
LPI exam objective 105.2
What it says
Read user input inside a shell script.

Practise this

Reading one question is not practice. The trainer will draw a set from objective 105 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500