Concept

Redirection (computing)

Résumé
In computing, redirection is a form of interprocess communication, and is a function common to most command-line interpreters, including the various Unix shells that can redirect standard streams to user-specified locations. In Unix-like operating systems, programs do redirection with the system call, or its less-flexible but higher-level stdio analogues, and . Redirection is usually implemented by placing certain characters between commands. Typically, the syntax of these characters is as follows, using < to redirect input, and > to redirect output. command > file1 executes , placing the output in , as opposed to displaying it at the terminal, which is the usual destination for standard output. This will clobber any existing data in . Using command < file1 executes , with as the source of input, as opposed to the keyboard, which is the usual source for standard input. command < infile > outfile combines the two capabilities: reads from and writes to To append output to the end of the file, rather than clobbering it, the >> operator is used: command1 >> file1. To read from a stream literal (an inline file, passed to the standard input), one can use a here document, using the < operator: $ tr a-z A-Z < END_TEXT
one two three uno dos tres END_TEXT ONE TWO THREE UNO DOS TRES To read from a string, one can use a here string, using the < operator: tr a-z A-Z < "one two three", or: NUMBERS="onetwothree"NUMBERS="one two three" tr a-z A-Z < "$NUMBERS" ONE TWO THREE Programs can be run together such that one program reads the output from another with no need for an explicit intermediate file. command1 | command2 executes , using its output as the input for (commonly called piping, with the "|" character being known as the "pipe"). The two programs performing the commands may run in parallel with the only storage space being working buffers (Linux allows up to 64K for each buffer) plus whatever work space each command's processing requires.
À propos de ce résultat
Cette page est générée automatiquement et peut contenir des informations qui ne sont pas correctes, complètes, à jour ou pertinentes par rapport à votre recherche. Il en va de même pour toutes les autres pages de ce site. Veillez à vérifier les informations auprès des sources officielles de l'EPFL.