Re: How to list the first 10 lines error from executing command

From: Ralf Fassel (ralfixx_at_gmx.de)
Date: 07/30/03


Date: 30 Jul 2003 14:19:45 +0200


* "JohnWu" <johnwu@yorku.ca>
| > javac file.java 2>&1 >/dev/null | head -10
| >
| > Joe
|
| Thanks, Joe
|
| In sh, it works, but I'm using tcsh and csh, it said that it was
| ambiguous redirect output, do you mind telling me again how to do it
| for tcsh, or csh?

You can't redirect stderr separate from stdout in csh, only both, like
this:

  javac file.java |& head -10
  javac file.java |& more

(man csh:
        A simple command, or a set of simple commands separated by |
     or |& characters, forms a pipeline. With |, the standard output
     of the preceding command is redirected to the standard input of
     the command that follows. With |&, both the standard error and
     the standard output are redirected through the pipeline.
)

So if there is stdout-output as well, you might have to wrap Joe's
suggestion inside a call to sh -c, or just invoke sh for that single
command.

R'



Relevant Pages

  • Re: Help adding a larger drive to Alphaserver
    ... }> stderr cannot be redirected by 2>..., ... } Just like moving between eunichs shells. ... Ever try 2> in csh? ... but you can't separately redirect 2. ...
    (comp.os.vms)
  • Re: Ambiguous output redirect
    ... "Ambiguous output redirect." ... or change your shell to a bourne shell compatible one like bash. ... PS In csh the ">&" means redirect to a file including stderr, in this case the file "1"; then you are telling it to also pipe to something, which is impossible since you just redirected to a file. ...
    (freebsd-questions)
  • Re: find
    ... > to redirect just stderr. ... there is no good way to do it with *csh but if someone wanted to do ... Quite the hack. ...
    (comp.unix.shell)
  • Re: Finally wrote-up my "How to Design Parts" section...
    ... csh and ksh also do file name completion, ... machines are offering csh simply as a link to tcsh. ... On Solaris 10 on Sun Ultra-2 machines, ... which I *also* have to download and compile before I can ...
    (rec.crafts.metalworking)
  • Re: Finally wrote-up my "How to Design Parts" section... / OT filenames
    ... machines are offering csh simply as a link to tcsh. ... shell can complete a partially typed filename or user name. ... I was using tcsh, ...
    (rec.crafts.metalworking)