- Standard Out (stdout) can be directed to a file via a redirect using several specific characters after the command
- REDIRECTIONS:
- Redirections can be used after a command to direct the Standard Out (stdout) to a file, or to use the information in a file as command variables:
- [ > ] creates a new file containing the stdout. If the file exists, it’s overwritten
- [ >>] appends stdout to the existing file. If it doesn’t exist, the file is created
- [ 2> ] creates a new file containing the Standard Error (stderr). if it doesn’t exist, the file is created
- [ 2>> ] appends Standard Error (stderr) to the existing file. If it doesn’t exist, the file is created
- [ &> ] creates a new file containing both Standard Out (stdout) and Standard Error (stderr)
- [ < ] sends the contents of the specific file to be used as Standard In (stdin)
- [ << ] accepts text on the following lines as Standard In (stdin)
- [ <> ] causes the specific file to be used for both Standard In (stdin) and Standard Out (stdout)
- Redirections can be used after a command to direct the Standard Out (stdout) to a file, or to use the information in a file as command variables:
- The PIPE:
- The pipe syntax ‘|’ can be used to execute multiple commands while ‘piping’ the Standard Out (stdout) to the next command
- Example : ‘command1 | command2 | command 3’ …output from 1 is used for 2, which is used for 3, and so on
- The ‘tee’ Command:
- splits Standard In (stdin) so that it’s displayed on Standard Out (stdout) and on as many files as specified
- used with a pipe so that a program’s output can be stored and viewed simultaneously
- Example : ‘program1 | tee outputfile.txt’