TransWikia.com

How to write output of a command to multiple files without displaying on screen

Unix & Linux Asked on December 29, 2021

Here in the example is date command.

I have tried

date &> file file2 file3

does not work

date | tee file file2 file3

works but also displays on the console

Is there a way if I can run date command and it displays output to multiple files and not on the terminal.

2 Answers

Use tee, but redirect the "final" stdout to /dev/null:

date | tee file file2 file3 >/dev/null

Answered by steeldriver on December 29, 2021

If you're using zsh, this construct works:

date > file1 > file2 > file3

If running in bash, only file3 will contain the output.

Answered by Panki on December 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP