Search code examples
bashstdoutio-redirectionqsubsungridengine

Redirect output file to stdout


In qsub Oracle Grid Engine, this redirects the output to a file out.txt,

qsub -o $(pwd)/out.txt -sync y awesome_script.sh

How to redirect the output to stdout ?


Solution

  • You can specify /dev/stdout as the filename.

    qsub -o /dev/stdout -sync y awesome_script.sh
    

    More info can be found in this answer: https://unix.stackexchange.com/questions/36403


    Edit:

    A common Unix idiom is that the filename - means stdin for an input file and stdout for an output file. This has to be explicitly handled by the program, though; it's not automatic. I can't find anything saying whether qsub uses this idiom. Try it, it might work.

    If you want to pipe the output to another command that does something with it, you could create a named pipe (man mkfifo) and send the output to that, with the other process reading from the pipe. Start the read process first.

    For another idea, see this answer, which explains how to use bash process substitution. I haven't used this much, but I think it would be something like:

    qsub -o >(other-command-or-pipeline) -sync y awesome_script.sh
    

    If you simply want to see the output in real-time, you could specify /dev/tty as the file. Or, you could output to a file and watch it with tail -f.

    Hope one of these ideas works for you.