Shell scripts with options and the most basic wording for shell scripts that combine while to make interactive selections

Source: Internet
Author: User

1, case do with the execution of the option script:

#!/bin/bash

Case $ in

X

echo "X is selected"

;;

*)

echo "Please use X"

Esac


Second, case combined while doing interactive script:

#!/bin/bash

While True

Do

Read-p "Enter Port of Chaoxingdata (d,1):" Port

Case ${port} in

D

echo "Port=${port}"

Read-p "Press ENTER to continue"

;;

1)

echo "Port=${port}"

Read-p "Press ENTER to continue"

;;

*)

echo "Error input,you fool"

Read-p ' type ' go ' to continue: ' Go

if [! ${go} = go] | | [-Z ${go}]

Then

Exit

Fi

Esac

Done

Shell scripts with options and the most basic wording for shell scripts that combine while to make interactive selections

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.