Example of the format of several control flow statements in Linux (if statement)

Source: Internet
Author: User

Examples of the format of several control flow statements for Linux:
Example of an if statement;
#!/bin/sh

a=10
B=20

if [$a = = $b]
Then
echo "A is equal to B"
elif [$a-gt $b]
Then
echo "A is greater than B"
elif [$a-lt $b]
Then
echo "A is less than B"
Else
echo "None of the condition met"
Fi


The IF ... else statement can also be written as a line and run as a command
if test $[2*3]-eq $[1+5]; Then echo ' The numbers is equal! '; Fi
The IF ... Else statement is also often used in conjunction with the test command
NUM1=$[2*3]
NUM2=$[1+5]
if test $[num1]-eq $[num2]
Then
Echo ' The numbers is equal! '
Else
Echo ' The numbers is not equal! '
Fi

Example of the format of several control flow statements in Linux (if statement)

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.