the usage of < /dev/null & in the command line

< /dev/null is used to instantly send EOF to the program, so that it doesn't wait for input (/dev/null, the null device, is a special file that discards all data written to it, but reports that the write operation succeeded, and provides no data to any process that reads from it, yielding EOF immediately). & is a special type of command separator used to background the preceding process.

Without knowing the program being called, I do not directly know why it is required to run it in this way.


</dev/null disconnects the program's input from the terminal. Some programs react differently depending on what their standard input is connected to. With the redirection </dev/null, the program can tell that its input is not coming from a terminal, and will receive an end-of-file indication immediately if it tries to read from its standard input.

The lone & at the end causes the program to be executed in the background. This means that you get a shell prompt back immediately. Without the &, you would get a shell prompt back only when the program finishes executing.

Note that the standalone & is unrelated to >&. >& is a redirection operator (in tcsh, bash and zsh) which redirects both the program's standard output and the program's standard error to the file name specified after the operator (here log).

In other words, what the shell does when it sees this command line is:

  • Start a process in the background. In the background process:
    • Connect standard input to /dev/null (the null device).
    • Connect both standard output and standard error to the file called log (creating the file if it doesn't exist yet, and truncating it if it exists).
    • Look for an executable file called java in the $PATH.
    • Execute that file with the 5 arguments -cp, /home/weka.jar, weka.classifiers.trees.J48, –t, train_file`.