当前位置: 技术问答>linux和unix
simple question on shell
来源: 互联网 发布时间:2015-07-12
本文导语: #!/bin/bash # intorstring.sh # Integer or string? a=2334 # Integer. let "a += 1" echo "a = $a " # Integer, still. echo b=${a/23/BB} # Transform into a string.?????????????????????? line 8 echo "b = $b" # BB35 why b become BB35??who can explain line...
#!/bin/bash
# intorstring.sh
# Integer or string?
a=2334 # Integer.
let "a += 1"
echo "a = $a " # Integer, still.
echo
b=${a/23/BB} # Transform into a string.?????????????????????? line 8
echo "b = $b" # BB35
why b become BB35??who can explain line 8
# intorstring.sh
# Integer or string?
a=2334 # Integer.
let "a += 1"
echo "a = $a " # Integer, still.
echo
b=${a/23/BB} # Transform into a string.?????????????????????? line 8
echo "b = $b" # BB35
why b become BB35??who can explain line 8
|
a+=1后
a的值是2335
a/23/BB,是正则表达式,把a字符串中的第一次匹配的23替换成BB,当然就变成BB35了。
a的值是2335
a/23/BB,是正则表达式,把a字符串中的第一次匹配的23替换成BB,当然就变成BB35了。
|
你使用了正则表达式,它就当成文本处理的