当我运行model=$(cat /proc/device-tree/model)时,我得到-bash: warning: command substitution: ignored null byte in input
bash --version
GNU bash, version 4.4.12(1)-release (arm-unknown-linux-gnueabihf)使用bash版本4.3.30,一切正常
我知道问题出在文件中的终止\0字符,但是我怎么才能抑制这条愚蠢的消息呢?我的整个脚本都搞乱了,因为我在bash 4.4上
发布于 2017-09-12 04:36:54
您可能需要两种可能的行为:
IFS= read -r -d '‘模型
model=$(tr -d '\0‘
您也可以只使用内置来实现它,如下所示:
model="“while IFS= -r -d '‘substring || [ $substring ];do model+="$substring”do substring
发布于 2017-09-12 04:33:30
如果您只想删除空字节:
model=$(tr -d '\0' < /proc/device-tree/model)https://stackoverflow.com/questions/46163678
复制相似问题