Shell Script Learning (1)

Source: Internet
Author: User

Format:

#!/bin/bash: Flag a shell script

#Filename: first_shell.sh: File name

#auto: echo "Hello Shell": role

#by author h0f 2018-03-08: Author-date

echo "Hello Shell": Execute content

Execution: chmod o+x first_shell.sh

./first_shell.sh

Or:/bin/bash first_shell.sh

echo $? Determine if the last command was successful

Echo-e "\033[32mpleasse Select menu follow: \033[1m" color adjustment

/bin/bash 1_shell.sh

If Judgment statement number size

Determine if the file exists:

The first time does not exist, then creates, the second execution shows the existence OK

Note: 1 "." The same functionality as the source command, read-in script and execute script

Note: 2. Brackets [] must have at least one space at each end, as well as double brackets [[]]

3. The value of the string definition variable for a regular variable should be double-quoted, and there must be no spaces before and after the equals sign, which requires a strong reference (referred to as a WYSIWYG character reference) to use single quotation marks (").

If it is a reference to the command, use the back quotation marks (• )。

4. Single quotes, double quotes, and anti-quotes in all scripts must be symbols in the English state.

Shell Script Learning (1)

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.