1

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, this works. My mistake was that I tried putting > /dev/null after the END. I will accept your answer.
To be honest, my first attempt was also like that :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.