Expr:non-numeric argument

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.