Discover how a simple symbol can save you hours of tedious typing!
Why stdin redirection (<) in Linux CLI? - Purpose & Use Cases
Imagine you have a long list of names saved in a file, and you want to run a command that processes each name one by one. Without redirection, you would have to type or copy-paste each name manually into the command prompt.
This manual typing is slow and tiring. It's easy to make mistakes like typos or missing lines. Also, repeating the same command for many inputs wastes time and energy.
Using stdin redirection with the < symbol, you can feed the contents of a file directly into a command as if you typed it yourself. This saves time, reduces errors, and automates the process smoothly.
command name1 command name2 command name3
command < names.txt
This lets you easily automate commands that need input, making your work faster and more reliable.
For example, if you have a file with a list of email addresses and want to send a welcome message using a command-line tool, you can redirect the file as input instead of typing each email manually.
Manual input is slow and error-prone.
Stdin redirection feeds file content directly to commands.
This makes automation simple and efficient.