What does esac mean?

Source: Internet
Author: User
Tags case statement

What does esac mean?

 

Some people who have just been familiar with Bash programming are always very strange about some keywords in Bash. They know its functions, but they don't know why to write them like this. For example:

 

#! /Bin/bash

 

If [! -N "$1"]

Then

Echo "Usage: $0 [insert | remove]";

Exit 1

Fi

 

Action = "$1"

Case $ action in

Insert) echo "device inserted .";;

Remove) echo "device removed .";;

*) Echo "invalid option .";;

Esac

 

FI is the end of the IF statement, and esac is the end of the case statement. Isn't the keyword like Fi and esac weird? Oh, think about it for a moment. I don't blame it at all. Consider {} [] and so on. {And} are vertical axial symmetry, and [and] are vertical axial symmetry. Now, if, Fi, case, and esac are the same? They are reversed, indicating start and end respectively.

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.