user4501715
user4501715

Reputation:

Stop printing of output when command is assingned to variable

G1_P1=`$HOME/X/Y/Z/ test -i`;

It is printing the output of test -i Example:

$HOME/X/Y/Z/ test -i

Testing is done

I do not want the output to be shown. I want it to store to variable G1_P1 but without showing the output.

Please help.

Upvotes: 1

Views: 127

Answers (1)

anubhava
anubhava

Reputation: 784998

It is not stdout output that is getting printed in terminal. It is the output written on stderr. You can do this:

G1_P1=$($HOME/X/Y/Z/test -i 2>/dev/null)

to suppress stderr output.

Or if you want stderr output also in variable then use

G1_P1=$($HOME/X/Y/Z/test -i 2>&1)

Upvotes: 1

Related Questions