Some summary of shell script usage

Source: Internet
Author: User


(1), the CSH script can call Bash's script, and vice versa.

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

(3). The variable defined, which defaults to a global variable. Local variables need to be specified locally to declare them. Column: Local value= "value",

The variable cannot be called in any other function or file.

(4). Execution is loaded (included)


L Example: the variable and function defined in test.sh are called in use.sh.

TEST.SH is defined as follows:

#!/bin/sh

function func

{

echo "The ARG is $"

Value= "$"

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 indicate the path to the containing 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 procedure.





Some summary of shell script usage

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.