Shell's/bin/bash script base combat

Source: Internet
Author: User

I rookie a, first contact with the Linux shell script;

Shell script, the simplest function is to write a lot of instructions together, so that users can easily be able to execute multiple commands, and shell script provides arrays, loops, conditions and logical judgments and other important functions, so that users can directly to the shell to write programs, Instead of using the syntax written by traditional programs like the C programming language.

Benefits of Shell scripting:

In some complex Linux operations, a large number of repetitive input and interaction operations can be done through Shell script batch processing, automated maintenance, thereby reducing the cost of labor.

The Linux shell script is a special kind of application, the common shell has many kinds, the view way can use Cat/etc/shells or chsh-l,:

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/83/9F/wKiom1d4iC3D1ZXQAAA-QK7_aX4919.jpg-wh_500x0-wm_3 -wmp_4-s_2320074477.jpg "title=" qq20160703113341.jpg "alt=" Wkiom1d4ic3d1zxqaaa-qk7_ax4919.jpg-wh_50 "/>

There are differences in the way the internal instructions are prompted by different shell scripts.

To write a shell script:

The operation commands, which are written in the usual order, are placed in the. Sh script file and given execute permissions. can be used normally.

Here's my first shell script:

Execute the command #vim first.sh enter "I" for editing.

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/83/9F/wKiom1d4lrCBLuQPAAAUqPkbEjg199.jpg-wh_500x0-wm_3 -wmp_4-s_2240872440.jpg "title=" qq20160703123753.jpg "alt=" Wkiom1d4lrcbluqpaaauqpkbejg199.jpg-wh_50 "/>

#! /bin/bash, in order to declare, writes the bash language, using the bash interpreter.

# This is my Firsh test script files. (Note information: Annotate the role of this script, in order to make a description in the production environment when other people see the script.) )

Mkdir/root/test Use the mkdir command to create a test directory under the/root/directory.

After creation, then execute ifconfig to view the IP information of the next machine.

There are 5 output modes, the following are common in the production environment (do not need to add the script to execute permissions):

1: #sh firsh.sh

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/83/9F/wKiom1d4mPHxNgNmAADhZzwqdYo456.jpg-wh_500x0-wm_3 -wmp_4-s_2382260564.jpg "title=" qq20160703124434.jpg "alt=" Wkiom1d4mphxngnmaadhzzwqdyo456.jpg-wh_50 "/>

2: #source firsh.sh

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/83/9E/wKioL1d4mQWSThlLAADhpiGs1X8682.jpg-wh_500x0-wm_3 -wmp_4-s_1497779784.jpg "title=" qq20160703124518.jpg "alt=" Wkiol1d4mqwsthllaadhpigs1x8682.jpg-wh_50 "/>

Now formally open your Shell's first script, hoping to help you.

This article is from the "11732822" blog, please be sure to keep this source http://11742822.blog.51cto.com/11732822/1795272

Shell's/bin/bash script base combat

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.