Recall & Review
beginner Click to reveal answer
What does the stdin redirection operator (<) do in Linux command line?
It takes input for a command from a file instead of the keyboard. The command reads data from the file as if it was typed by the user.
beginner Click to reveal answer
How would you use stdin redirection to provide a file named
input.txt as input to the sort command?You write:
sort < input.txt. This tells sort to read its input from input.txt instead of waiting for keyboard input.intermediate Click to reveal answer
True or False: Using
command < file is the same as cat file | command.True. Both send the contents of the file as input to the command, but
< is simpler and more efficient.beginner Click to reveal answer
What happens if you use stdin redirection with a file that does not exist?
The shell will show an error like
bash: file: No such file or directory and the command will not run.beginner Click to reveal answer
Why is stdin redirection useful in scripting and automation?
It lets scripts read input from files automatically without user typing. This helps run commands on saved data quickly and repeatably.
What does the operator < do in a Linux command?
✗ Incorrect
The < operator takes input from a file and feeds it to the command as if typed by the user.
Which command uses stdin redirection correctly?
✗ Incorrect
Option A uses < to send file.txt contents as input to grep.
What error occurs if the file used with < does not exist?
✗ Incorrect
The shell reports an error because it cannot find the file to redirect input from.
How is < different from a pipe (|)?
✗ Incorrect
< redirects input from a file; pipe sends output from one command to another.
Why prefer < over cat file | command?
✗ Incorrect
< is simpler syntax and more efficient because it avoids creating an extra process.
Explain how stdin redirection (<) works and give a simple example.
Think about how a command reads data without typing.
You got /3 concepts.
Describe a situation where stdin redirection helps automate a task.
Imagine you want to process many files quickly.
You got /3 concepts.
