linux_wiki:use_input-output_redirection

Differences

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

Link to this comparison view

linux_wiki:use_input-output_redirection [2016/02/28 22:48]
billdozor created
linux_wiki:use_input-output_redirection [2019/05/25 23:50]
Line 1: Line 1:
-====== Use Input-output Redirection ====== 
- 
-**General Information** 
- 
-Using input/output redirection (>, >>, |, 2>, etc.). 
- 
----- 
- 
-**> Redirect standard output to a file, overwrite contents** 
-<code bash> 
-cat /etc/system-release > info.txt 
-</code> 
- 
-**>> Redirect standard output to file, append to file** 
-<code bash> 
-tail /etc/passwd >> info.txt 
-</code> 
- 
-**| Piping output to other commands** 
-<code bash> 
-cat /etc/passwd | wc -l 
-</code> 
-Count the number of lines in /etc/passwd 
- 
-**2> Redirect standard error** 
-<code bash> 
-ssh admin@webserver01.com "uptime" 2>/dev/null 
-</code> 
-SSH to webserver01.com, issue the uptime command, send standard errors to /dev/null (to nowhere) 
- 
-**Redirect both standard error and standard output** 
-<code bash> 
-ssh admin@webserver01.com "uptime" &> results.log 
-</code> 
- 
-**Redirect standard error to standard out** 
-<code bash> 
-cat /etc/system-release /etc/Red 2>&1 | grep Red 
-</code> 
-Standard output can be passed through a pipe to the next command. By redirecting standard error to standard output, any error messages are successfully sent through as well. 
- 
----- 
  
  • linux_wiki/use_input-output_redirection.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)