Difference between revisions of "Standard input (/dev/stdin)"

From wikieduonline
Jump to navigation Jump to search
 
(16 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
[[wikipedia:stdin]]
 
[[wikipedia:stdin]]
  
* <code>2>&1</code>
+
* <code>[[2]]>&1</code>
 
* <code>&></code>
 
* <code>&></code>
  
 
* <code>[[sudo]] -S</code> or <code>[[sudo]] --stdin</code>
 
* <code>[[sudo]] -S</code> or <code>[[sudo]] --stdin</code>
 +
 +
 +
https://unix.stackexchange.com/questions/61931/redirect-all-subsequent-commands-stderr-using-exec
 +
#!/bin/bash -
 +
 +
exec > >([[tee]] "$HOME/somefile.log") [[2]]>[[&1]]
 +
 +
echo "$HOME"
 +
echo hi
 +
echo "Command to err but will be redirected to stdout" 1>&2
 +
command_that_pipes_output_to_stderr_but_will_be_redirected_to_stdout
 +
echo "End script"
  
 
== Activities ==
 
== Activities ==
 
* [[Compress]] data from <code>[[stdin]]</code>: <code>echo "DATA TO COMPRESS" | [[xz]] --verbose > file.xz</code>
 
* [[Compress]] data from <code>[[stdin]]</code>: <code>echo "DATA TO COMPRESS" | [[xz]] --verbose > file.xz</code>
* <code>[[docker logs]] 2>&1 | grep TEXT </code>
+
* <code>[[docker logs]] [[2]]>[[&1]] | grep TEXT </code>
 +
 
 +
== Related terms ==
 +
* <code>[[tee]]</code>
 +
* <code>[[/dev/null]]</code>
 +
* <code>[[file descriptor]]</code>
 +
* <code>[[logger]]</code>
 +
* <code>[[gcloud]]</code>
  
 
== See also ==
 
== See also ==
* {{cat}}
+
* {{echo}}
 
* {{stdin}}
 
* {{stdin}}
 
* {{Bash}}
 
* {{Bash}}
* {{Performance}}
 
  
 
[[Category:Linux]]
 
[[Category:Linux]]

Latest revision as of 11:37, 15 February 2024

This article is a Draft. Help us to complete it.

wikipedia:stdin

  • 2>&1
  • &>


https://unix.stackexchange.com/questions/61931/redirect-all-subsequent-commands-stderr-using-exec
#!/bin/bash -

exec > >(tee "$HOME/somefile.log") 2>&1

echo "$HOME"
echo hi
echo "Command to err but will be redirected to stdout" 1>&2
command_that_pipes_output_to_stderr_but_will_be_redirected_to_stdout
echo "End script"

Activities[edit]

Related terms[edit]

See also[edit]

Advertising: