|
Prev: Reading from a file
Next: Filtering chars with sed
From: Name withheld by request on 22 Apr 2008 09:38 I do not understand why 'Binary file (standard input) matches' goes to STDOUT, why not to STDERR?: ~ $ date;uname -sr Tue Apr 22 08:35:42 CDT 2008 Linux 2.6.5-1.358 ~ $ printf "hi\000"|egrep hi >foo ~ $ cat foo Binary file (standard input) matches ~ $
From: Stephane CHAZELAS on 22 Apr 2008 09:46 2008-04-22, 13:38(+00), Name withheld by request: > I do not understand why 'Binary file (standard input) matches' goes > to STDOUT, why not to STDERR?: > > ~ $ date;uname -sr > Tue Apr 22 08:35:42 CDT 2008 > Linux 2.6.5-1.358 > ~ $ printf "hi\000"|egrep hi >foo > ~ $ cat foo > Binary file (standard input) matches > ~ $ Maybe because it's not an error. -- St�phane
From: Kenny McCormack on 22 Apr 2008 10:44 In article <slrng0rr2i.7b0.stephane.chazelas(a)spam.is.invalid>, Stephane CHAZELAS <this.address(a)is.invalid> wrote: >2008-04-22, 13:38(+00), Name withheld by request: >> I do not understand why 'Binary file (standard input) matches' goes >> to STDOUT, why not to STDERR?: >> >> ~ $ date;uname -sr >> Tue Apr 22 08:35:42 CDT 2008 >> Linux 2.6.5-1.358 >> ~ $ printf "hi\000"|egrep hi >foo >> ~ $ cat foo >> Binary file (standard input) matches >> ~ $ > >Maybe because it's not an error. And maybe the sun rises in the east. And yet you can see where he is coming from. In some sense, the term "standard error" is a misnomer. It really is/should be "Out of Band". Really, the standard error channel should be used for any OOB type information - that is, other than the actual, genuine output of the command.
From: Stephane CHAZELAS on 22 Apr 2008 10:58 2008-04-22, 14:44(+00), Kenny McCormack: [...] >>> ~ $ printf "hi\000"|egrep hi >foo >>> ~ $ cat foo >>> Binary file (standard input) matches >>> ~ $ >> >>Maybe because it's not an error. > > And maybe the sun rises in the east. > > And yet you can see where he is coming from. In some sense, the term > "standard error" is a misnomer. It really is/should be "Out of Band". > > Really, the standard error channel should be used for any OOB type > information - that is, other than the actual, genuine output of the command. In which way isn't the "Binary file (..." message "actual, genuine output of grep"? It seems to me that it carries information requested by the user (can "hi" be found in the standard input?). -- St�phane
From: Bill Marcum on 22 Apr 2008 11:40
On 2008-04-22, Name withheld by request <anonb6e9(a)nyx3.nyx.net> wrote: > > > I do not understand why 'Binary file (standard input) matches' goes > to STDOUT, why not to STDERR?: > > ~ $ date;uname -sr > Tue Apr 22 08:35:42 CDT 2008 > Linux 2.6.5-1.358 > ~ $ printf "hi\000"|egrep hi >foo > ~ $ cat foo > Binary file (standard input) matches > ~ $ > It's normal for (e)grep to produce output if it finds a match. If the input were not considered binary, the matching line(s) would be output. You can use the -a option to force *grep to treat its input as plain text, or you can pipe the output of strings to *grep if you don't want strange things to happen to your terminal. |