The output from the file command (as is the case with head or any other command) can easily be redirected to another file using the output redirection operator. In this case, it tells the file command to consider every file in the current directory as an argument. The asterisk is a wildcard that means all or everything. Thus, the following will display on the monitor screen a list containing the name and type of every file in the current directory (i.e., the directory in which the user is currently working): It sends to standard output a line containing the file name and type for each file whose name is provided to it as an argument (i.e., an input). The output redirection operator will cause the contents of file2 to be overwritten if a file with the same name already exists, and it will create a file with that name if it does not yet exist.Īs another example, the file command is used to report the types of files, such as whether they are text, HTML, GIF, WAV or compressed files or whether they are links or directories (which are both treated as types of files in Unix-like operating systems). That is, the output from file1 is written to file2 instead of being displayed on the screen. In the following example the output redirection operator, which is represented by a rightward pointing angular bracket, is used to redirect head's output from the display screen to a file named file2: Redirection operators can be used to redirect the output of a command line program from the display screen to a file where it is written and saved, to a printer where it is printed, or to another program where it is used as an input. Thus, for example, the following command will cause the head program, whose default behavior is to read the first ten lines of any specified files, to send the first ten lines of the file named file1 to the display screen: Because the standard streams are plain text, they are by definition human readable. That default destination is the display screen on the computer that initiated the program. One of the features of standard output is that it has a default destination but can easily be redirected (i.e., diverted) to another destination. The introduction of standardized streams represented a major breakthrough in the computer field when it was incorporated into the original UNIX operating system more than three and a half decades ago, because it eliminated the very complex and tedious requirement of having to adjust the output of each program according to the specific device or program to which it was being sent. These standardized streams, which consist of plain text, make it very easy for the output from such programs to be sent to a devices (e.g., display monitors or printers) or to be further processed by other programs. Standard output, sometimes abbreviated stdout, refers to the standardized streams of data that are produced by command line programs (i.e., all-text mode programs) in Linux and other Unix-like operating systems. ![]() What is standard output? - definition by The Linux Information Project (LINFO) LINFO
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |