User Tools

Site Tools


ops102:redirection

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ops102:redirection [2024/02/01 19:43] – [Piping] chrisops102:redirection [2024/05/04 02:26] (current) – external edit 127.0.0.1
Line 2: Line 2:
 =====  Standard File Descriptors  ===== =====  Standard File Descriptors  =====
  
-On Linux, other Unix-like systems, and on Windows, programs may open **file descriptors** (Linux terminology) or **handles** (Windows terminology). Each file descriptor/handle is a numbered channel connected to a file or device.+On Linux, other Unix-like systems, and on Windows, programs may open **file descriptors** (Linux terminology) or **file handles** (Windows terminology). Each file descriptor/handle is a numbered channel connected to a file or device.
  
 By default, three channels are opened automatically by the shell when a process is started. These are: By default, three channels are opened automatically by the shell when a process is started. These are:
Line 107: Line 107:
  -rw-r--r--. 1 chris chris 0 Sep 26 13:17 one  -rw-r--r--. 1 chris chris 0 Sep 26 13:17 one
  -rw-r--r--. 1 chris chris 0 Sep 26 13:17 two</code>  -rw-r--r--. 1 chris chris 0 Sep 26 13:17 two</code>
 +
 +Note that in this example, it is necessary to redirect stdout before redirecting stderr to the same location.
  
 =====  Piping  ===== =====  Piping  =====
  
-Piping is a special case of redirection, where the output of one command is connected to the input of another command. This is set up using the vertical-bar (pipe) symbol: ''|'' (this may look like a solid or a dashed vertical line, depending on the terminal font in use).+Piping is a special case of redirection, where the output (stdout) of one command is connected to the input (stdin) of another command. This is set up using the vertical-bar (pipe) symbol: ''|'' (this may look like a solid or a dashed vertical line, depending on the terminal font in use).
  
 For example, on Windows, the output of the ''help'' command is more than one screen long. You could pipe the output of the ''help'' command into the input of the ''more'' command to view one screen of text at a time: For example, on Windows, the output of the ''help'' command is more than one screen long. You could pipe the output of the ''help'' command into the input of the ''more'' command to view one screen of text at a time:
Line 137: Line 139:
  -- More  --</code>  -- More  --</code>
  
-Press the ENTER key to scroll by one line, or the spacebar to scroll by one screen.+Press the ENTER key to scroll by one line, the spacebar to scroll by one screen, or "q" to quit.
  
 Similarly, on Linux, a long directory listing could be redirected to ''more'', or better yet, the improved ''less'' command: Similarly, on Linux, a long directory listing could be redirected to ''more'', or better yet, the improved ''less'' command:
Line 166: Line 168:
  drwxr-xr-x.  2 root root     4096 Aug 24 20:00 bluetooth  drwxr-xr-x.  2 root root     4096 Aug 24 20:00 bluetooth
  drwxr-xr-x.  2 root root     4096 May 30 09:32 bonobo-activation  drwxr-xr-x.  2 root root     4096 May 30 09:32 bonobo-activation
-></code>+:</code>
  
-Like ''more'', you can press ENTER to scroll by one line or SPACE to scroll by one screen; but you can also use the up/down arrow keys, or the PgUp/PgDn keys, to scroll in either direction by one line or one screen.+Like ''more'', you can press ENTER to scroll by one line or SPACE to scroll by one screen, or "q" to quit; but you can also use the up/down arrow keys, or the PgUp/PgDn keys, to scroll in either direction by one line or one screen.
  
 On Windows, to see the ''help'' lines that mention color, you could feed the output of the ''help'' command into the ''find'' command: On Windows, to see the ''help'' lines that mention color, you could feed the output of the ''help'' command into the ''find'' command:
ops102/redirection.1706816631.txt.gz · Last modified: 2024/04/16 18:10 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki