Programming Basics for Shell scripts

Source: Internet
Author: User
Tags shebang

Program: Instruction + data

Program Programming Style:

Program: command-centric, data-serving instruction

Object type: Data-centric, instruction serves data

Shell program: Provides programming capabilities to interpret execution


How to handle the programming logic:

Sequential execution

Loop execution

Select Execute

Shell programming: procedural, interpreting execution

The basic structure of the programming language:

A combination of various system commands

Data storage: variables, arrays

Expression: A + b

Statement: If

Shell script:

A text file that contains some commands or declarations and conforms to a certain format

Format requirements: First line shebang mechanism

#! /Bin/bash

#! /usr/bin/python

#!/usr/bin/perl

The uses of shell scripts are:

Automating common commands

Perform system administration and troubleshooting

Create a simple application

Working with text or files


Create a shell script

First step: Use a text editor to create a text file

The first line must include the shell declaration sequence: #!

#! /bin/bash

Add Comment

Comments start with #

Step two: Run the script

Give execute permission to specify the absolute or relative path of the script on the command line

Run the interpreter directly and run the script as a parameter of the interpreter program


Scripting specifications

1. The first line is generally the language used for the call

2. Program name, avoid changing the file name to not find the correct file

3. Version number

4. Time after the change

5. Related information of the author

6. The role of the procedure, and matters needing attention

7. Finally, a brief description of the updates for each version


Basic structure of the script

#! Shebang

CONFIGURATION Vriables

Function_definitions

Main_code



Programming Basics for Shell scripts

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.