Command+redirection

= Console = With command redirection one can redirect [|standard streams] like //stdin//, //stdout// and //stderr// to user-specified locations. Quite often it is useful to redirect the output of a program to a text file. code format="text" someProgram >/some/where/output.txt    (Linux/Unix Bash) someProgram >c:\some\where\output.txt  (Windows command prompt) code code format="text" someProgram 2>/some/where/output.txt    (Linux/Unix Bash) someProgram 2>c:\some\where\output.txt  (Windows command prompt) code code format="text" someProgram &>/some/where/output.txt        (Linux/Unix Bash) someProgram >c:\some\where\output.txt 2>&1  (Windows command prompt) code code format="text" java weka.classifiers.trees.J48 -t train.arff -T test.arff -p 0 2> j48.txt code or if one already has a trained model: code format="text" java weka.classifiers.trees.J48 -l j48.model -T test.arff -p 0 2> j48.txt code
 * redirecting //stdout// to a file
 * redirecting //stderr// to a file
 * redirecting //stdout// and //stderr// to a file
 * Note:** under Weka quite often the output is printed to //stderr//, e.g., if one is using the //-p 0// option from the commandline to print the predicted values for a test file:

= SimpleCLI = With version >3.5.5 (or from Subversion/snapshot after 30/04/2007) one can perform a basic redirection also in the SimpleCLI, e.g.: code format="text" java weka.classifiers.trees.J48 -t test.arff > j48.txt code
 * Note:** the **>** must be preceded and followed by a //space//, otherwise it is not recognized as redirection, but part of another parameter.

= Links =
 * Linux
 * [|Command redirection under Bash]
 * [|I/O Redirection under Bash]
 * [|Redirection under Unix (WikiPedia)]
 * Windows
 * [|Command redirection under MS Windows]
 * [|Command redirection under MS DOS]