input/output redirection
input/output redirection
(operating system)To redirect input to come from a file instead of the keyboard,use "
myprog < myfile
Similarly to redirect output to a file instead of the screen:
ls > filelist
A pipe redirects the output of one process directly into theinput of another
who | wc -l
A common misuse by beginners is
cat myfile | myprog
Which is more or less equivalent to "myprog < myfile" exceptthat it introduces an extra unnecessary cat process and bufferspace for the pipe. Even the "
Unix's concept of standard input/output and I/O redirectionmake it easy to combine simple processes in powerful ways andto use the same commands for different purposes.