File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes less or > doesn't always work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "less or > doesn Watch "less or > doesn New topic

less or > doesn't always work

sonny kher
Ranch Hand

Joined: Nov 06, 2001
Posts: 83
when I try to pipe output from a build file to less or to a file, it doens't always catch everything. Why so?
ant > tempFile only writes like a couple of lines when the screen stdout sees like 50
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
There are actually two output streams (corresponding to System.out and System.err in Java). The '>' redirection only redirects the basic output stream, not the errors stream..
To redirect the error stream use 2>

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
Hi - One (among several) neat trick is:
some_command 2>&1 | tee logfile.txt
I agree. Here's the link:
subject: less or > doesn't always work
It's not a secret anymore!