If the Case statement is not executed, let's see why ....
Source: Internet
Author: User
If the Case statement is not executed, let's see why .... -- Linux general technology-Linux programming and kernel information. The following is a detailed description. Today, I wrote a simple shell script to test the case statement and found a strange phenomenon. The procedure is as follows:
#! /Bin/sh
Echo 'hit a key, then Hit return .'
Read Keypress
Case "$ Keypress" in
[A-z]) echo "Lowercase letter ";;
[A-Z]) echo "Uppercase letter ";;
[0-9]) echo 'digit ';;
*) Echo 'punctuation, whitespace, or other ';;
Esac
When running, it is found that the second case is always not running, and the Lowercase letter is still printed when uppercase letters are entered.
When I change a-z]) echo "Lowercase letter"; and [A-Z]) echo "Uppercase letter, when you enter lower-case letters, the Uppercase letter is displayed!
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