0

I know how to use tee, of course, I have used it many times. However, it is normally something like:

du -h /some/directory | sort -h | tee census

While this works fine, it means I don't see anything until almost near the end, because sort needs to collect the whole list of output from du. What I'm thinking of could be good is if it is possible to do something along the lines of:

du - h | tee stderr | sort -h > census

where obviously stderr would be some notation to represent the real error output channel. I haven't found anything in the rather sparse documentation - is it it possible?

0

1 Answer 1

1

If you write to /dev/stderr with tee, a copy of the data is written to the standard error stream and will not be sent to the next part of the pipeline:

some-command | tee /dev/stderr | sort -h -o census

The difference between that and

some-command | sort -h | tee census

... is obviously that the data you will see in the former case is unsorted and occurs on the standard error stream rather than sorted and on the standard output stream as in the latter case.

1
  • Ah, yes, of course, I should have thought as far as /dev/... - thanks! Commented May 28, 2024 at 12:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.