in reply to pipe concepts
Piping is a method of handing over these filehandles to other processes, allowing one command to work with the output of another. Unix systems tend to implement features with tiny commands that do one thing. This allows the user to string several commands together to accomplish a goal.#... print "Tell me your name.\n" # Implied "print <STDOUT> ..." chomp(my $name = <STDIN>); unless ($name) { print STDERR "User did not provide a name...\n"; } #...
This would start the following commands: ps, grep, awk, mail. The STDOUT belonging to ps would become STDIN on grep, and so on. Eventually, a message would be mailed to the user "kgale" with only the second column (process ID) of lines containing the word "perl" from the output of "ps" (system process list). Since a standard pipe only redirects STDIN and STDOUT, STDERR would continue to be sent to the user's console. For more information on how piping is implemented on your particular shell, check your shell's man page:$ ps auxw | grep perl | awk ' {print $2} ' | mail -s "Perl PIDs" kgale
$ man `basename $SHELL`
|
|---|