Search code examples
bashshkshno-op

Pipe that does nothing


I'm on a AIX box and need a program that when used after a pipe does nothing.

I'll be more exact. I need something like this:

if [ $NOSORT ] ; then
    SORTEXEC="/usr/bin/doesnothing"
else
    SORTEXEC="/usr/bin/sort -u"
fi
# BIG WHILE HERE
do

done | SORTEXEC

I tried to use tee > /dev/null, but I don't know if there is another better option available.

Can anybody help with a more appropriate program then tee?

Thanks in advance


Solution

  • Use tee as follows:

    somecommand | tee
    

    This just copies stdin to stdout.

    Or uUse true or false. All they do is exit EXIT_SUCCESS or EXIT_FAILURE.

    somecommand | true
    

    Notice, every output to stdout from somecommand is dropped.

    Another option is to use cat:

    somecommand | cat