stdin ot stdout - Solaris
This is a discussion on stdin ot stdout - Solaris ; Till now I can not the difference between STDIN command and STDOUT
command till now.
Give me pls example .
Is cat stdin ?
Is ls stdout or stdin ?...
-
stdin ot stdout
Till now I can not the difference between STDIN command and STDOUT
command till now.
Give me pls example .
Is cat stdin ?
Is ls stdout or stdin ?
-
Re: stdin ot stdout
ehabaziz2001@gmail.com wrote:
>Till now I can not the difference between STDIN command and STDOUT
>command till now.
They're not commands, they're files.
>Is cat stdin ?
"cat" reads the file you specify on the command line and writes it to
STDOUT.
--
Tim Slattery
Slattery_T@bls.gov
-
Re: stdin ot stdout
On 2006-04-07, ehabaziz2001@gmail.com wrote:
> Till now I can not the difference between STDIN command and STDOUT
> command till now.
>
> Give me pls example .
>
> Is cat stdin ?
> Is ls stdout or stdin ?
They are not commands, they (along with stderr) are streams
connected to a process. When a program uses read (or fread or
whatever any particular language uses) it is, by default, reading
from stdin. When a program outputs something (e.g., with printf),
it is sent to stdout.
#! /bin/sh
read var ## read a line from stdin
printf "%s\n" "$var" ## print to stdout
By default, stdin is connected to a keyboard, and stdout and
stderr are sent to your screen.
On the command line, these may be redirected to a file or a pipe:
read line < /etc/passwd ## connect read's stdin to the file /etc/passwd
printf "%s\n" "$line" > $HOME/xxx ## send the line to the file $HOME/xxx
In this example, the stdout of printf is connect to a pipe; that
pipe is connected to the stdin of tr:
printf "%s\n" "$line" | tr ':' '\n'
--
Chris F.A. Johnson, author |
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence