-1
外壳引号中提取内容我有一个字符串,它看起来像:巴什 - 从可变
result='SNMP OK - "-63.1" |' # output should be -63.1
result='SNMP OK - "63.1" |' # output should be 63.1
我需要引号之间的输出的一切 - 这应该始终是数字。
外壳引号中提取内容我有一个字符串,它看起来像:巴什 - 从可变
result='SNMP OK - "-63.1" |' # output should be -63.1
result='SNMP OK - "63.1" |' # output should be 63.1
我需要引号之间的输出的一切 - 这应该始终是数字。
var='SNMP OK - "-63.1"';
newvar=$(echo "$var" | sed -r 's/.*"(.*)".*/\1/')
echo "$newvar"
-63.1
什么是您的输入字符串? – Inian
SNMP OK - “-63.1”| – user2680315
这看起来很像http://superuser.com/questions/515421/using-sed-get-substring-between-two-double-quotes –