Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
-bash:警告:命令替换:忽略输入中的空字节_Bash_Variables_Calculation - Fatal编程技术网

-bash:警告:命令替换:忽略输入中的空字节

-bash:警告:命令替换:忽略输入中的空字节,bash,variables,calculation,Bash,Variables,Calculation,我总是很紧张 -bash: warning: command substitution: ignored null byte in input 执行以下代码时出现警告: BW=`bc <<< "$(cat $TMP | grep -Pzo '(?<="outgoing_traffic": )(.*)(?=,)')/1024^3"` 但该代码不起作用: BW=tr -d '\0' < `bc <<< &q

我总是很紧张

-bash: warning: command substitution: ignored null byte in input
执行以下代码时出现警告:

BW=`bc <<< "$(cat $TMP | grep -Pzo '(?<="outgoing_traffic": )(.*)(?=,)')/1024^3"`
但该代码不起作用:

BW=tr -d '\0'  < `bc <<< "$(cat $TMP | grep -Pzo '(?<="outgoing_traffic": )(.*)(?=,)')/1024^3"`

得到警告是因为
grep-z
在结果末尾输出一个零字节,而shell无法处理这个问题。简单的解决方案是放弃该选项,或者找到一种方法用shell实际能够处理的东西替换它。实际上,它在这里似乎没有任何用处。。。但可能会丢失并使用现代命令替换语法,而不是过时的backticks,以及


BW=$(请看这是否有用-请查找上面的更新。
BW=tr -d '\0'  < `bc <<< "$(cat $TMP | grep -Pzo '(?<="outgoing_traffic": )(.*)(?=,)')/1024^3"`
-bash: warning: command substitution: ignored null byte in input
-bash: `bc <<< "$(cat $TMP | grep -Pzo '(?<="outgoing_traffic": )(.*)(?=,)')/1024^3"`: No such file or directory
BW=`bc <<< "$(cat $TMP | grep -Pzo '(?<="outgoing_traffic": )(.*)(?=,)')/1024^3"`
echo $BW
-bash: warning: command substitution: ignored null byte in input
4
bash$ echo hello | tr '\n' '\0' | xxd
00000000: 6865 6c6c 6f00                           hello.