Stdout: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Labner (talk | contribs)
No edit summary
Labner (talk | contribs)
No edit summary
Line 10: Line 10:
Tavaliselt on standardsisendiks klaviatuurilt sisestatav tekst ja standardväljund ning standarderror kuvatakse ekraanile.
Tavaliselt on standardsisendiks klaviatuurilt sisestatav tekst ja standardväljund ning standarderror kuvatakse ekraanile.


== stdin ümbersuunamine ==
Vaikimisi suunatakse stdout sisu ekraanile. Selleks, et stdout faili suunata tuleb kasutada > märki. Näiteks:
<code>ls > file_list.txt</code>
In this example, the ls command is executed and the results are written in a file named file_list.txt. Since the output of ls was redirected to the file, no results appear on the display.
Each time the command above is repeated, file_list.txt is overwritten (from the beginning) with the output of the command ls. If you want the new results to be appended to the file instead, use ">>" like this:
[me@linuxbox me]$ ls >> file_list.txt
When the results are appended, the new results are added to the end of the file, thus making the file longer each time the command is repeated. If the file does not exist when you attempt to append the redirected output, the file will be created.. To redirect standard output to a file, the ">" character is used like this:
[me@linuxbox me]$ ls > file_list.txt
In this example, the ls command is executed and the results are written in a file named file_list.txt. Since the output of ls was redirected to the file, no results appear on the display.
Each time the command above is repeated, file_list.txt is overwritten (from the beginning) with the output of the command ls. If you want the new results to be appended to the file instead, use ">>" like this:
[me@linuxbox me]$ ls >> file_list.txt
When the results are appended, the new results are added to the end of the file, thus making the file longer each time the command is repeated. If the file does not exist when you attempt to append the redirected output, the file will be created.


==Autor==
==Autor==

Revision as of 12:13, 9 January 2017

mustand

stdout (standard output) on UNIX süsteemides standardväljund. Vt. ka stdin ja stderr

Standardvood

Joonis 1. The standard streams for input, output, and error. Allikas: https://en.wikipedia.org/wiki/Standard_streams

Linuxis ja teistes Unix-i laadsetes süsteemides on kasutusel standard andmevood. Iga protsess käivitatakse automaatselt koos kolme andmevooga: sisendvoog stdin ja väljundvood stdout (standard output) ja stderr (standard error). Need vood kujutavad endast spetsiaalset tüüpi faili ja võivad sisaldada plain text andmeid.[1]

Igale avatud failile omistatakse ka arvuline deskriptor. stdin, stdout ja stderr arvulised failideskriptorid on vastavalt 0,1 ja 2. Tüüpiliselt on need vood seotud terminaliga (tty), kuid võivad ka viidata teistele failidele või seadmetele, kui protsess on vastavalt seadistatud. [2] Tavaliselt on standardsisendiks klaviatuurilt sisestatav tekst ja standardväljund ning standarderror kuvatakse ekraanile.

stdin ümbersuunamine

Vaikimisi suunatakse stdout sisu ekraanile. Selleks, et stdout faili suunata tuleb kasutada > märki. Näiteks: ls > file_list.txt

In this example, the ls command is executed and the results are written in a file named file_list.txt. Since the output of ls was redirected to the file, no results appear on the display.

Each time the command above is repeated, file_list.txt is overwritten (from the beginning) with the output of the command ls. If you want the new results to be appended to the file instead, use ">>" like this:

[me@linuxbox me]$ ls >> file_list.txt

When the results are appended, the new results are added to the end of the file, thus making the file longer each time the command is repeated. If the file does not exist when you attempt to append the redirected output, the file will be created.. To redirect standard output to a file, the ">" character is used like this:

[me@linuxbox me]$ ls > file_list.txt

In this example, the ls command is executed and the results are written in a file named file_list.txt. Since the output of ls was redirected to the file, no results appear on the display.

Each time the command above is repeated, file_list.txt is overwritten (from the beginning) with the output of the command ls. If you want the new results to be appended to the file instead, use ">>" like this:

[me@linuxbox me]$ ls >> file_list.txt

When the results are appended, the new results are added to the end of the file, thus making the file longer each time the command is repeated. If the file does not exist when you attempt to append the redirected output, the file will be created.

Autor

Liina Abner
DK23
jaanuar 2017

Allikad