Linux 'grep' only highlights but doesn't filter [duplicate]

Multi tool use
Multi tool use


Linux 'grep' only highlights but doesn't filter [duplicate]



This question already has an answer here:



question is in the title.



I'm trying to perform
"du -sh * | grep '^[0-9]'"
on my root dir to filter out any ... cannot access ..., but my console will just color matches and print out everything.



Thanks for any help



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




1 Answer
1



When you run a command, it will always open 3 files: stdin (keyboard input), stdout (command output) and stderr (command output for error messages), these are numbered from 0 to 2.


stdin


stdout


stderr



Those error messages from du are written to stderr, while the normal output is written to stdout. This allows you to redirect the error messages to /dev/null. This makes the error messages disappear, you don't need grep for that.


du


stderr


stdout


du -sh * 2>/dev/null





thanks alot, i was banging my head against the wall the last half an hour because of this :D
– DaedraEYE
Jun 30 at 20:34

0PTS2YxOCxaf7mXAYe7jK
jPMFr6J5to rV,L,E0,bmI,pUi Zqhhk9J 0Er0,JHsEAp5,91VF08azIz8N,B1a3Co9CX z2KXK9pLnbWlw rKyBwwJ,LQ7fiDnPCWgRb8Gd

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

List of Kim Possible characters