0
0
Linux CLIscripting~15 mins

stdin redirection (<) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Using stdin Redirection (<) in Linux CLI
📖 Scenario: You have a text file with a list of names. You want to use a command that reads from this file as if you typed the names directly into the command.
🎯 Goal: Learn how to use stdin redirection (
📋 What You'll Learn
Create a text file named names.txt with specific names.
Use stdin redirection (<) to pass the file content to the cat command.
Display the content of the file using the command with stdin redirection.
💡 Why This Matters
🌍 Real World
Many Linux commands can read input from files using stdin redirection. This helps automate tasks without typing input manually.
💼 Career
Understanding stdin redirection is essential for system administrators, developers, and anyone working with command-line tools to automate workflows.
Progress0 / 4 steps
1
Create the names.txt file
Create a file called names.txt with these exact three lines: Alice, Bob, and Charlie.
Linux CLI
Need a hint?

Use the echo command with -e to add new lines and redirect output to names.txt.

2
Prepare to use stdin redirection
Use the cat command with stdin redirection (<) to read from the file names.txt. Write the command without running it.
Linux CLI
Need a hint?

Use cat < names.txt to read the file content through stdin redirection.

3
Run the command with stdin redirection
Run the command cat < names.txt to display the content of names.txt using stdin redirection.
Linux CLI
Need a hint?

Just run the command cat < names.txt and observe the output.

4
Confirm understanding by printing a message
Print the message File content displayed using stdin redirection after showing the file content.
Linux CLI
Need a hint?

Use printf or echo to print the message after the file content.