Why are redirections not working following assignment?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
./NulFile
contains NUL. When command expansion removes NUL from it, it outputs warnings. Is there some way to suppress the warnings?
Why are redirections not working?
$ filecontent="$(cat ./NulFile)" 1>/dev/null 2>&1
bash: warning: command substitution: ignored null byte in input
bash io-redirection command-substitution
New contributor
add a comment |
up vote
0
down vote
favorite
./NulFile
contains NUL. When command expansion removes NUL from it, it outputs warnings. Is there some way to suppress the warnings?
Why are redirections not working?
$ filecontent="$(cat ./NulFile)" 1>/dev/null 2>&1
bash: warning: command substitution: ignored null byte in input
bash io-redirection command-substitution
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
./NulFile
contains NUL. When command expansion removes NUL from it, it outputs warnings. Is there some way to suppress the warnings?
Why are redirections not working?
$ filecontent="$(cat ./NulFile)" 1>/dev/null 2>&1
bash: warning: command substitution: ignored null byte in input
bash io-redirection command-substitution
New contributor
./NulFile
contains NUL. When command expansion removes NUL from it, it outputs warnings. Is there some way to suppress the warnings?
Why are redirections not working?
$ filecontent="$(cat ./NulFile)" 1>/dev/null 2>&1
bash: warning: command substitution: ignored null byte in input
bash io-redirection command-substitution
bash io-redirection command-substitution
New contributor
New contributor
New contributor
asked Nov 21 at 14:00
Ben
2788
2788
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
Put it in a command group and redirect the output of the group:
$ foo=$(cat /bin/sleep)
bash: warning: command substitution: ignored null byte in input
$ foo=$(cat /bin/sleep); 2>/dev/null
$
Because ...;
isn't a subshell, the variable will still be available.
$ echo $#foo
19786
The warning is from the shell, and you need to redirect the shell's output for it to work. In the group, even the shell's output is redirected (only within that group).
New contributor
It works. Do you know why my command didn't work?
– Ben
Nov 21 at 14:11
That's the last paragraph of my answer.
– Arcticooling
Nov 21 at 14:15
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Put it in a command group and redirect the output of the group:
$ foo=$(cat /bin/sleep)
bash: warning: command substitution: ignored null byte in input
$ foo=$(cat /bin/sleep); 2>/dev/null
$
Because ...;
isn't a subshell, the variable will still be available.
$ echo $#foo
19786
The warning is from the shell, and you need to redirect the shell's output for it to work. In the group, even the shell's output is redirected (only within that group).
New contributor
It works. Do you know why my command didn't work?
– Ben
Nov 21 at 14:11
That's the last paragraph of my answer.
– Arcticooling
Nov 21 at 14:15
add a comment |
up vote
2
down vote
Put it in a command group and redirect the output of the group:
$ foo=$(cat /bin/sleep)
bash: warning: command substitution: ignored null byte in input
$ foo=$(cat /bin/sleep); 2>/dev/null
$
Because ...;
isn't a subshell, the variable will still be available.
$ echo $#foo
19786
The warning is from the shell, and you need to redirect the shell's output for it to work. In the group, even the shell's output is redirected (only within that group).
New contributor
It works. Do you know why my command didn't work?
– Ben
Nov 21 at 14:11
That's the last paragraph of my answer.
– Arcticooling
Nov 21 at 14:15
add a comment |
up vote
2
down vote
up vote
2
down vote
Put it in a command group and redirect the output of the group:
$ foo=$(cat /bin/sleep)
bash: warning: command substitution: ignored null byte in input
$ foo=$(cat /bin/sleep); 2>/dev/null
$
Because ...;
isn't a subshell, the variable will still be available.
$ echo $#foo
19786
The warning is from the shell, and you need to redirect the shell's output for it to work. In the group, even the shell's output is redirected (only within that group).
New contributor
Put it in a command group and redirect the output of the group:
$ foo=$(cat /bin/sleep)
bash: warning: command substitution: ignored null byte in input
$ foo=$(cat /bin/sleep); 2>/dev/null
$
Because ...;
isn't a subshell, the variable will still be available.
$ echo $#foo
19786
The warning is from the shell, and you need to redirect the shell's output for it to work. In the group, even the shell's output is redirected (only within that group).
New contributor
New contributor
answered Nov 21 at 14:08
Arcticooling
1
1
New contributor
New contributor
It works. Do you know why my command didn't work?
– Ben
Nov 21 at 14:11
That's the last paragraph of my answer.
– Arcticooling
Nov 21 at 14:15
add a comment |
It works. Do you know why my command didn't work?
– Ben
Nov 21 at 14:11
That's the last paragraph of my answer.
– Arcticooling
Nov 21 at 14:15
It works. Do you know why my command didn't work?
– Ben
Nov 21 at 14:11
It works. Do you know why my command didn't work?
– Ben
Nov 21 at 14:11
That's the last paragraph of my answer.
– Arcticooling
Nov 21 at 14:15
That's the last paragraph of my answer.
– Arcticooling
Nov 21 at 14:15
add a comment |
Ben is a new contributor. Be nice, and check out our Code of Conduct.
Ben is a new contributor. Be nice, and check out our Code of Conduct.
Ben is a new contributor. Be nice, and check out our Code of Conduct.
Ben is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483214%2fwhy-are-redirections-not-working-following-assignment%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown