Basic knowledge of Shell programming

Source: Internet
Author: User

1. Use the editor to write a file, which is the command entered in the shell, can be used through the PATH environment variable reference to the command.

#! /bin/sh #! The following parameter is the program used to execute the script

#后面是注释

The rest is like writing in the shell.

Note that the last to add exit+ exit code, Shell 0 indicates success.

1 #! /bin/sh2#简单示例 3"hello,world"

2. Set the script to executable

There are two ways to execute a script

(1) Script name as parameters of shell

$/bin/sh Hello

(2) Change the mode of this file, add executable

chmod +x Hello

Note: The shell environment variable path is not set to look for commands in the current directory,

If there are two ways to make an error

1) plus the full path name./hello (recommended in this way)

2) Direct input Command PATH = $PATH:. Or this edit the. bash_profile file, add hello to the end of the file

(Note: The method of modifying the path variable may create a security issue)

Syntax for 3.shell

Not to be continued

Basic knowledge of Shell programming

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.