Skip to content

Files

Latest commit

 

History

History
25 lines (15 loc) · 670 Bytes

SC2260.md

File metadata and controls

25 lines (15 loc) · 670 Bytes

Pattern: Redirection overrides the output pipe

Issue: -

Description

A process only has a single standard output stream. Pipes and output redirections both overwrite it, so you can't use both at the same time. If you try, the redirection takes precedence and the output pipe is closed.

If you want to dump output to a file while also piping it, use tee as in the example.

Example of incorrect code:

env > environment.txt | grep '^ANDROID'

Example of correct code:

env | tee environment.txt | grep '^ANDROID'

Further Reading