Today to do a calculation, the script is as follows:
#!/bin/bashhit=$ (/app/local/redis/bin/redis-cli-h 127.0.0.1-p 6379 info | grep "keyspace_hits" | awk-f ': ' {print $} ') miss=$ (/app/local/redis/bin/redis-cli-h 127.0.0.1-p 6379 info | grep "keyspace_misses" | awk-f ': ' {print $} ') All= ' exp R $HIT + $MISS ' echo $all
Run Error:expr:non-numeric argument, the final various tests, alone to hit and miss assignment, no error, that is, do not know where the reason, view run verbose mode:
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/8C/C2/wKiom1h3BxHjUKapAABGTc2RXHU237.png "title=" 13. PNG "alt=" Wkiom1h3bxhjukapaabgtc2rxhu237.png "/>
Look carefully, behind the "\ R", thinking it is the problem of coding
# cat-v 1.sh #!/bin/bashhit=$ (/app/local/redis/bin/redis-cli-h 127.0.0.1-p 6379 info | grep "keyspace_hits" | awk-f ': ' ' {print $} ') miss=$ (/app/local/redis/bin/redis-cli-h 127.0.0.1-p 6379 info | grep "keyspace_misses" | awk-f ': ' {print All= ' expr $HIT + $MISS ' echo $all
Did not find where there is a problem, forget it, or first turn it:
Yum Install Dos2unix
Turn format:
# Dos2unix 1.sh dos2unix:converting file 1.sh to UNIX format ...
Do it again, or not:
# sh 1.sh expr:non-numeric argument
I want to try and delete the "\ r".
Sed-i "" s/\r//"" 1.sh
Execute or not:
# sh 1.sh expr:non-numeric argument
Finally dawned, "\ r" is the result of the calculation brought out!!!
To modify a script:
# vim 1.sh #!/bin/bashhit=$ (/app/local/redis/bin/redis-cli-h 127.0.0.1-p 6379 info | grep "keyspace_hits" | awk-f ': ' { Print $} ') miss=$ (/app/local/redis/bin/redis-cli-h 127.0.0.1-p 6379 info | grep "keyspace_misses" | awk-f ': ' {print $ } ') echo $HITecho $MISSHIT 1= ' echo $HIT | Tr-d ' \ R ' miss1= ' echo $MISS | Tr-d ' \ r ' all= ' expr $HIT 1 + $MISS 1 ' echo $all
Re-execution:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8C/BF/wKioL1h3Byuj7Ms6AABPkH8zpO0488.png "title=" 14. PNG "alt=" Wkiol1h3byuj7ms6aabpkh8zpo0488.png "/>
Really fuck the dog, unexpectedly this small problem, wasted me half an hour, so to be serious!
This article is from the "take a deep Breath again" blog, make sure to keep this source http://ckl893.blog.51cto.com/8827818/1891323
Expr:non-numeric argument