Shell Script [op-expression, conditional-control statement]

Source: Internet
Author: User
Tags shebang

#!/bin/bash#你值得收藏的四则表达式运算. val1=1Val2=1val3=1val4=1val5=1val6=1val7=1 Letval1++ ((val2++)) val3=$ (($val 3+1)) val4= ' expr$val 4+1' Val5= ' bc<<<$val 5+1' Val6= 'Echo "$val 6+1"|BC ' val7=$[$val 7+1]Echo ' val1= ' $val 1Echo ' val2= ' $val 2Echo ' val3= ' $val 3Echo ' val4= ' $val 4Echo ' val5= ' $val 5Echo ' val6= ' $val 6Echo ' val7= ' $val 7

You should be aware of conditional control statements.

#!/bin/bash#Val=1ifTest$val -eq 1; ThenEcho "Hello word!"fi#!/bin/bash#Val=1if[$val -eq 1]; ThenEcho "Hello word!"fi#!/bin/bash#Val=1[$val -eq 1] && {Echo "Hello word!"}#[]//does not support regular expressions, it is a system command. #[[]]//supports regular expressions, but not system commands. #!/bin/bashVal=1[[$val -eq 1]] && {Echo "Hello word!"}
#!/bin/bash#输入一个用户判断该用户是否存在. #read-P "Please input your User:" User#a = ' cut-d ': "-f1/etc/passwd| grep "$USER" ' while true Do   if["$USER"=="$a"]; Then       Echo "Yes!this user is exit!!!"        Break    Else       Echo "This user no Exit!!!"       Read-P"Please input it again:"USER a= ' cut- D ":" - F1/etc/passwd| Grep"$USER"`fi Done

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Shell Script [op-expression, conditional-control statement]

Related Article

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.