Summary of using shell scripts

Source: Internet
Author: User

Summary of using shell scripts

(1) The csh script can call the bash script, and vice versa.

(2). How to call variables and functions defined in other scripts.

(3). Defined variables. The default value is global variables. You must specify local to declare local variables. Column: local value = "Value ",

This variable cannot be called by other functions or files.

(4). Execute load (including)

L example: Call the variables and functions defined in test. sh in use. sh.

Test. sh is defined as follows:

#! /Bin/sh

Function func

{

Echo "the arg is $1"

Value = "$1"

Echo "Value =$ {Value }"

}

Function main

{

Echo "-- main start ---"

Func "test"

Echo "--- main end ---"

}

The following is the definition of main. sh:

#! /Bin/sh

Source./test. sh # (or ../test. sh), you need to specify the path containing the file --- (4)

Echo "--- use start ---"

Main

Echo "call value =$ {Value }"

Echo "--- use end ---"

---------------------

Execute main. sh (or sh-x main. sh)

You can see the call process.

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.