Data streams (Bash): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 1: Regel 1:
A ''stream'' or ''datastream'' is something that can transfer data. Whenever running a command in Bash, the three default data streams, ''stderr'', ''stdin'' and ''stnout'' are activated. They all three carry data. Amongst other things, streams are relevant for ''piping'' and ''redirection''.
+
A ''stream'' or ''datastream'' is something that can transfer data. Whenever running a command in Bash, the three default data streams, ''stderr'', ''stdin'' and ''stnout'' are activated. They all three carry data. Amongst other things, streams are relevant for ''piping'' and ''redirection''. Streams have ''endpoints'', and these enables them to connect commands to each other and/or to files.
  
 +
The three basic streams - They all use text:
 +
 +
* ''stdin'': ''Standard input''
 +
* ''stout'': ''Standard output''
 +
* ''sterr'': ''Standard error''.
 +
 +
Like lots of things in Unix and Linux, they correspond with files and devices.
 +
 +
Examples:
 +
 +
* stdin: When using <code>read</code> for input from the user, stdin is used to capture what is typed
 +
* stout: When using <code>ls</code>, stout sends the content of the directory to the console
 +
* sterr: When generating an error, sterr sends the error message from the interpreter (or whatever) to the screen.
  
 
== See also ==
 
== See also ==
Regel 6: Regel 19:
 
* [[Mapfile (Bash)]]
 
* [[Mapfile (Bash)]]
 
* [[Pipelining & redirection (Bash)]]
 
* [[Pipelining & redirection (Bash)]]
 +
 +
 +
== Sources ==
 +
 +
* https://linuxhint.com/bash_stdin_stderr_stdout/

Versie van 24 okt 2022 14:02

A stream or datastream is something that can transfer data. Whenever running a command in Bash, the three default data streams, stderr, stdin and stnout are activated. They all three carry data. Amongst other things, streams are relevant for piping and redirection. Streams have endpoints, and these enables them to connect commands to each other and/or to files.

The three basic streams - They all use text:

  • stdin: Standard input
  • stout: Standard output
  • sterr: Standard error.

Like lots of things in Unix and Linux, they correspond with files and devices.

Examples:

  • stdin: When using read for input from the user, stdin is used to capture what is typed
  • stout: When using ls, stout sends the content of the directory to the console
  • sterr: When generating an error, sterr sends the error message from the interpreter (or whatever) to the screen.

See also


Sources