Question

I want to insert commands into an interactive environment using the following method:

bc <<END
1+1
quit
END

The output of the example is '2' and it appears after typing END. Suppose I would want to suppress this output. So after typing END I don't want any output to appear. How could I accomplish this?

Was it helpful?

Solution

You can accomplish it redirecting the output of bc to /dev/null:

$ bc &>/dev/null <<END
1+1
quit
END

Note that using & > /dev/null both stdout and stderr will be sent to /dev/null, so not output will appear at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top