You can redirect standard input in Unix-like operating systems using the < operator. This allows you to take input for a command or program from a file instead of the keyboard.
Here’s the basic syntax:
command < inputfile
In this command, inputfile is the file from which the input will be read.
Example
Suppose you have a text file named data.txt that contains some input data. You can redirect the contents of this file to a program that reads from standard input. For example:
sort < data.txt
In this case, the sort command will read the contents of data.txt as if the user had typed it in manually.
Using with Programs
If you have a program that reads from standard input, you can also redirect input to it. For example, if you have a C program compiled to myprogram, you can run:
./myprogram < inputfile
This will feed the contents of inputfile into myprogram as standard input.
