79748838

Date: 2025-08-28 08:48:25
Score: 0.5
Natty:
Report link

To expand a bit on @BenjiWiebe answer.

One can also discard the stdout of tee with:

echo "something" | tee file1.txt file2.txt file3.txt 1>/dev/null

Although this way it is not posible to mix overwrite with append (unless piped again to other tee).

Use this to mix overwrite and append:

# overwrite file1.txt and append to file2.txt and file3.txt
echo "something" | tee file1.txt | tee -a file2.txt file3.txt 1>/dev/null
# same as
echo "something" | tee -a file2.txt file3.txt > file1.txt

In the end tee and unix pipes are quite flexible, one can then decide what combination makes more sense in a script.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @BenjiWiebe
  • Low reputation (0.5):
Posted by: manero