How to redirect ALL output from a command in Linux

3

I'm running Gentoo Linux. A program (equery) outputs a massive list of all the currently installed packages (equery list "*"). I want to find out which of them are unstable. Equery marks the unstable packages with [ ~] before the package name. The matter is that it only happens when the output is not redirected anywhere - in the terminal. When I try grepping the output (equery list "*" | grep "~") or redirecting it to a file, including stderr (equery list "*" &> eql.txt) that information is not redirected - only the names of the packages.

So, how do I redirect ALL the output from a program?

John Ashpool

Posted 2014-03-02T18:29:36.113

Reputation: 189

Is the info still printed to your terminal with &> or is it simply no longer printed at all? – terdon – 2014-03-02T18:50:16.593

It is not printed at all when redirecting with &>. – John Ashpool – 2014-03-02T18:51:35.777

1OK, then it's not a matter of redirection, the issue is that equery detects it is being redirected and modifies its output accordingly. Various commands can do this. Try equery list "*" 2>&1 | grep "~" does that work? – terdon – 2014-03-02T19:04:43.180

By the way, I answered your original question about list of unstable packages here

– VL-80 – 2014-03-02T19:09:36.030

And equery will not output ~ without y option which you can not combine with list option. – VL-80 – 2014-03-02T19:12:28.950

Answers

3

Try wrapping your equery command with unbuffer.

unbuffer equery list "*" | grep "-"

The unbuffer command makes its argument program think it's connected to a terminal. You may have to add another level of quoting to the "*" argument.

garyjohn

Posted 2014-03-02T18:29:36.113

Reputation: 29 085

2I love the bug on that man page! Lol – Canadian Luke – 2014-03-02T20:31:55.503

1

equery -N turns off pipe detection.

So equery -N list '*' | grep '~' should do the job.

Jan Düpmeier

Posted 2014-03-02T18:29:36.113

Reputation: 11