This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: bash : stderr & more (pipe for stderr)


> From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com]On Behalf
> Of Alex Vinokur

> How to use pipe for stderr?

This is a Bash-question, not cygwin - i.e. off topic here ;-)


$ cat t.c 
#include <stdio.h>

int main(int argc, char **argv) {

  if (argc<=1)
    printf("Use: %s [o] [e]\n" \
           " o - print short text on stdout\n" \
           " e - print short text on stderr\n",argv[0]);
  else {

    if ((argc>1) && (argv[1][0]=='o'))
      fprintf(stdout,"%s: This text on stdout\n",argv[0]);
        
    if ((argc>2) && (argv[2][0]=='e'))
      fprintf(stderr,"%s: This text on stderr\n",argv[0]);
      
    }
    
return 0;
}
$ gcc t.c 
$ ls -l a.exe
-rwxr-xr-x    1 Hannu       19876 Jun 14 13:02 a.exe*

$ a o e 2>&1 | less

-- less display --
a: This text on stdout
a: This text on stderr
-- end --


/Hannu E K Nevalainen, 59~14'N, 17~12'E
 ~ <=> degree

-- 

--END OF MESSAGE-- 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]