Difference between revisions of "Stdout, stderr and stdin"

From Linuxintro
imported>ThorstenStaerk
(wow! Now I discovered something new)
 
imported>ThorstenStaerk
Line 1: Line 1:
Piping is a famous concept in Unix that describes the handling of input and output of running processes. Think of a process that asks for your name. You enter your name by using the keyboard. But instead of reading from the keyboard, the process could also read from the standard input stream. And by default, the standard input stream could be fed by the keyboard.
+
Piping is a famous concept in Unix that describes the handling of input and output of running processes. Think of a process that asks for your name. You enter your name by using the keyboard. But instead of reading from the keyboard, the process could also read from the standard input stream. And by default, the standard input stream could be fed by the keyboard. You can then exchange the keyboard against the output of another process.
  echo hallo | (read a; echo $a)
+
 
 +
I mean the following. Here you start a process that asks you for your name and greets you then:
 +
  # (echo -n "how is your name? "; read name; echo "hallo $name")
 +
You type in the name on the keyboard and the command reads from standard input which comes from the keyboard.

Revision as of 20:17, 1 April 2009

Piping is a famous concept in Unix that describes the handling of input and output of running processes. Think of a process that asks for your name. You enter your name by using the keyboard. But instead of reading from the keyboard, the process could also read from the standard input stream. And by default, the standard input stream could be fed by the keyboard. You can then exchange the keyboard against the output of another process.

I mean the following. Here you start a process that asks you for your name and greets you then:

# (echo -n "how is your name? "; read name; echo "hallo $name")

You type in the name on the keyboard and the command reads from standard input which comes from the keyboard.