문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top