Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Standard and IO redirection     - Linux System Getting Started Learning: Change the name of the network interface on CentOS7 (Linux)

- Linux system components Detailed log (Linux)

- Ubuntu 14.04 compile and install Apache (Server)

- JDK comes with tools jinfo (Linux)

- Using packet capture libpcap be reconciliation package in Ubuntu 14.04 64 bits (Linux)

- Linux cut Command Study Notes (Linux)

- Hadoop 2.7.1 Installation and Configuration under RedHat Linux 6.5 (Server)

- Linux server disk expansion and Oracle tablespace file migration operations (Database)

- TOAD connect DB2 error SQL1460N solve (Database)

- Java Concurrency: synchronized (Programming)

- Install the latest Eclipse IDE in Ubuntu (Linux)

- Xshell key authentication mechanism using a remote login Linux (Linux)

- Thrift 0.9.3 compiler installation under Ubuntu (Linux)

- System-level alias vs Oracle ADR functionality (Database)

- MySQL concat function is SQL injection (Linux)

- Bootstrap 3.3.5 release download, Web front-end UI framework (Linux)

- Git uses a standard process (Linux)

- RedHat Linux 6 desktop installation (Linux)

- MySQL view (Database)

- to compile FFmpeg In Ubuntu (Linux)

  Standard and IO redirection
  Add Date : 2016-10-09      
  1, The standard input / output / error

When the shell is started, it inherits three files: stdin, stdout, stderr, normally the standard input from a keyboard, standard output and standard error is usually the screen.
Standard input / output / error file descriptor 0,1,2

2, redirection operators

<& Redirect input, followed by a number format file descriptor

> Redirect output

>> Append output

2> Redirect error

&> Redirect error and output, followed by the file name

> & Redirection error and output, followed by the file name or file descriptor digital format

2> & 1 redirects the standard error to standard output

1> & 2 redirects standard output to standard error

> | Covering noclobber redirect output, that is, if the file exists overwrite file

<> Filename If the file is a device, put the file as standard input and standard output

3 Examples

1) The standard error is redirected to a file
$ Cc prog.c 2> errfile

2) The standard output is redirected to a file, standard error file redirected to the null device
$ Cc prog.c> logfile 2> / dev / null

3) the standard output and standard error are directed to a file or file descriptor
$ Cc prog.c &> logfile // must be a file name
$ Cc prog.c> & logfile // can be a file name or file descriptor digital format
$ Cc prog.c> & 1 // standard output and standard error will be redirected to the standard output, standard output file descriptor 1

4) The standard output is redirected to a file, the standard error is redirected to the standard output device orientation
$ Cc prog.c> logfile 2> & 1
Equivalent to
$ Cc prog.c> & logfile
- Linux System Getting Started Learning: complete installation on Debian or Ubuntu kernel source (Linux)
- Merge Sort (Programming)
- Android 5.1 OTA package compilation error (Programming)
- CentOS Nginx achieve 3 virtual machine load balancing (Server)
- Using BBED repair ORA-01190 error (Database)
- How to make GRub instead of the default Ubuntu software center (Linux)
- To install Xen in Ubuntu 12.04 (Linux)
- Hadoop virtualization performance comparison and tuning experience (Server)
- Teach you self-built Linux firewall free (Linux)
- Java memory-mapped file MappedByteBuffer (Programming)
- ActiveMQ5.11.1 and JDK version matching relation (Linux)
- Mistakenly deleted redo log file group being given the lead to start the database ORA-03113 (Database)
- Access.log Apache access log analysis and how to import it into MySQL (Server)
- Binary tree traversal recursive and non-recursive (cyclic) traversal achieve (Programming)
- Ubuntu iptables prevent IP attacks (Linux)
- How to modify the Emacs Major Mode Shortcuts (Linux)
- Java enum use (Programming)
- awk Programming Model (Programming)
- Example of use WebSocket (Programming)
- Ubuntu Series Installation Docker (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.