Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Stack Overflow

1. About
2. Products
3. For Teams

2.

3.

Join Stack Overflow to learn, share knowledge, and build your career.

1.

Home

2.
1. Public
2.

2.  Stack Overflow
3.

Tags

4.

Users

5. Find a Job
6.

Jobs

7.
Companies

1. 

Teams

What’s this?

2.

3.

2.

Create a Team

Pipe to multiple files, but not stdout


Asked 7 years, 11 months ago
Active 2 years ago
Viewed 8k times
11
2

I want to pipe stdout to multiple files, but keep stdout itself quiet. tee is close but it prints to
both the files and stdout

$ echo 'hello world' | tee aa bb cc


hello world

This works but I would prefer something simpler if possible

$ echo 'hello world' | tee aa bb cc >/dev/null


bash stdout tee
Share
Improve this question
Follow
asked Mar 7 '13 at 7:15
Steven Penny
78.6k4848 gold badges303303 silver badges347347 bronze badges

 3

In tee aa bb cc, tee has to write 3 files, and you still have bash redirecting standard
output to a file. In tee aa bb > cc, you have the bash redirect, but tee only needs to
write to 2 files. I'd say the 2nd is more efficient, but only in the strictest sense; you'll
never notice the difference. – chepner Mar 7 '13 at 13:39

Add a comment

2 Answers
17

You can simply use:

echo 'hello world' | tee aa bb > cc


Share
Improve this answer
Follow
answered Mar 7 '13 at 7:22

anishsane
17.4k55 gold badges3232 silver badges6262 bronze badges
Add a comment
5

You can also close tee stdout output by writing to /dev/full

echo 'hello world' | tee aa bb cc >/dev/full

or by closing stdout.

echo 'hello world' | tee aa bb cc >&-

Be however aware that you will get either tee: standard output: No space left on
device or tee: standard output: Bad file descriptor warnings.

Share
Improve this answer
Follow
edited Jan 31 '19 at 21:08
answered Nov 20 '15 at 2:03

Jirka
10711 silver badge33 bronze badges

 1

/dev/null, not /dev/full – anishsane Jan 26 '16 at 10:59

 2

Not. it's indeed /dev/full so that the pipe is closed. With /dev/null, tee will still
continue to write, even if there is no space left for files aa, bb and cc. – Jirka Jan 31 '19
at 21:08

Add a comment

Your Answer
















Sign up or log in

Post as a guest

Name

Email

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie
policy

Not the answer you're looking for? Browse other questions


tagged bash stdout tee or ask your own question.
The Overflow Blog

 Why are video calls so tiring? You might be misreading cultural styles

 

Podcast 312: We’re building a web app, got any advice?

Featured on Meta
 Opt-in alpha test for a new Stacks editor
 Visual design changes to the review queues

Related

118
How do I get both STDOUT and STDERR to go to the terminal and a log file?

1116
How to redirect output to a file and stdout

736
Redirect stderr and stdout in Bash

3445
How do I tell if a regular file does not exist in Bash?

1047
Pipe to/from the clipboard in Bash script

1619
How to redirect and append both stdout and stderr to a file with Bash?

1051
How can I pipe stderr, and not stdout?

249
How to pipe stdout while keeping it on screen ? (and not to a output file)

2
Send stdout to file no tee

0
Bash redirections. Stdout to shell and stdout+stderr to file

Hot Network Questions

 Tool to help precision drill 4 holes in a wall?


 Is oxygen really the most abundant element on the surface of the Moon?
 Supervisor has said some very disgusting things online, should I pull my name from our
paper?
 How long was a sea journey from England to East Africa 1868-1877?
 OptionsPattern does not match rule with compound left hand side
 Would Trump's defence work in other courts?
 Do Traditional 401(k), FSA, and HSA contributions reduce your tax liability even if you
don't itemize?
 How to get self-confidence when writing?
 First year Math PhD student; My problem solving skill has been completely atrophied
and continues to decline
 Could I use a blast chiller to make modern frozen meals at home?
 How to break out of playing scales up and down when improvising
 How big does a planet have to be to appear flat for human sized observer?
 Vietnamese Coffee (cocktail) - what to sub for condensed milk?
 Why does the engine dislike white in this position despite the material advantage of a
pawn and other positional factors?
 Is room and board a qualified expense?
 Why is mathematica so slow when tables reach a certain length
 Should lenses be stored without their caps inside a dry cabinet?

more hot questions


Question feed
https://stac

Stack Overflow

 Questions
 Jobs
 Developer Jobs Directory
 Salary Calculator
 Help
 Mobile
 Disable Responsiveness

Products

 Teams
 Talent
 Advertising
 Enterprise

Company

 About
 Press
 Work Here
 Legal
 Privacy Policy
 Terms of Service
 Contact Us
Stack Exchange
Network

 Technology
 Life / Arts
 Culture / Recreation
 Science
 Other

 Blog
 Facebook
 Twitter
 LinkedIn
 Instagram

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa.
rev 2021.2.12.38568

You might also like