Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: qwertmonkey@syberianoutpost.ru Newsgroups: comp.lang.java.programmer Subject: trying to redirect both std out and err to a file together and still err to a separate file Date: Tue, 28 Aug 2012 23:59:35 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 55 Message-ID: NNTP-Posting-Host: z9Rq+Ge+SLJPEkk9TGcnaw.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: NetComponents Xref: csiph.com comp.lang.java.programmer:18372 I tested your suggestion with some java code and it works nicely ~ lbrtchx comp.unix.shell: trying to redirect both std out and err to a file together and still err to a separate file ~ import java.util.Locale; import java.util.Date; import java.text.DateFormat; // __ public class Test{ public static void main(String[] args){ DateFormat DF = DateFormat.getDateInstance(DateFormat.FULL, Locale.FRANCE); // __ std out System.out.println("// __ out.println: |" + DF.format(new Date()) + "|"); DF = DateFormat.getDateInstance(DateFormat.FULL, Locale.CHINESE); // __ std err System.err.println("// __ err.println: |" + DF.format(new Date()) + "|"); // __ Exception in thread "main" java.lang.NullPointerException DF = null; DF.format(new Date()); } } /* rm -f *.log export _DT=`date +%Y%m%d%H%M%S_%s` echo ${_DT} (javac Test.java 2>&1 >&3 | tee ${_DT}"_errc.log" >&3) 3> ${_DT}"_errc.log" (java Test 2>&1 >&3 | tee ${_DT}"_err.log" >&3) 3> ${_DT}"_err_out.log" ls -l *.log cat *_err.log cat *_err_out.log */