On Windows, one can use > NUL
to redirect a pipe to nothing. On Linux, one uses > /dev/null
. Is there a cross-platform compatible way to redirect a pipe to nothing for both platforms? In other words, I would be able to use this and not worry about which platform the command is executing on.
For example, I would like to be able to write the following commands as one command.
echo Hello > NUL
echo Hello > /dev/null
Of course, anything more complicated would require separate scripts. The use case is a single command being executed from cross-platform language (e.g. Java, Python). I would like to avoid having to detect the platform and instead use a generic solution.
Furthermore, the use case is such that 100s of machines will be accessed and installing would be more complex than simply detecting the platform and adapting the command.