EX200 Create simple shell scripts Practice Question
Which shell built-in can be used to read user input during script execution?
⚠ Common exam trap
Red Hat often tests the distinction between output commands (echo, printf) and input commands, expecting candidates to know that `read` is the only built-in among the options that directly captures user input into a variable.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
read
The `read` built-in command is specifically designed to capture user input from standard input (stdin) during script execution, storing it in one or more variables. This makes it the correct choice for interactive scripts that require runtime input from the user.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
read
Why this is correct
read is a shell builtin that reads a line from standard input and splits it into words using IFS, assigning them to the listed variable names; when no variable is supplied, it stores the entire line in REPLY. Because it runs in the current shell process rather than a child process, the assigned variables remain available afterward, which is exactly what an interactive prompt requires. Its exit status reflects whether a line was actually read, so it also works in while loops.
- ✗
printf
Why it's wrong here
printf is a shell builtin (and standalone utility) that formats and writes its arguments to standard output using a format string; it never reads from stdin. Its Bash-specific -v var option stores formatted output into a variable, but that variable contains the produced text, not input from the user, so printf cannot collect a response for a shell prompt.
- ✗
cat
Why it's wrong here
cat is an external utility that reads files and writes them to stdout; with no arguments it reads stdin, but it simply streams the entire input until EOF rather than returning one line with the read system call's semantics. It produces no IFS-based variables, no set exit status for end-of-file versus a successful line, and any captured output requires command substitution that trims trailing newlines, making it inappropriate for line-oriented interactive input.
- ✗
echo
Why it's wrong here
echo is a shell builtin (or /bin/echo) whose only purpose is to write its arguments to standard output; it has no input-reading mode and never inspects stdin. Options such as -n or -e alter how the arguments are rendered, but they do not cause echo to capture a line from the terminal or a pipe, so it cannot be used to obtain user input.
Go deeper
Related to this question
About these practice questions
Courseiva writes every EX200 question from scratch — 427 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This EX200 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX200 exam.