Linux-shell First Lesson

Source: Internet
Author: User
Tags define function

Linux-shell First Lesson

1, through a small example to introduce the shell

#! /bin/sh Call Sehll

echo Print content read input cd jump directory pwd View current directory

650) this.width=650; "title=" 1.jpg "src=" https://s5.51cto.com/wyfs02/M00/8D/EA/ Wkiol1ivmfixitxkaaaulf37ymw005.jpg-wh_500x0-wm_3-wmp_4-s_1085938692.jpg "alt=" Wkiol1ivmfixitxkaaaulf37ymw005.jpg-wh_50 "/>

2, define two variables, and find a fit.

A=5
B=6
c=$ (($a + $b))
Echo $c

3, define the variable, and the value of the variable plus 5.

D=9
Let "d+=5"
Echo $d

4. Calling functions

Func1 ()
{
num=105;
Echo $num
}
Func2 ()
{
Local num=13//setting locals
Echo $num
}
Func1
Func2

5. Define function and delete function

Hello ()
{
echo "hello,world!"
}
Hello
Unset-f Hello//delete function

Hello

6. Transmission parameters

#!/bin/sh
Tesfunc ()
{
echo "$# total delivery of $ #个值"
echo "value is: [Email protected]"
}
Tesfunc a b c d E F


#!/bin/sh
Tesfunc ()
{
echo "$# total delivery of $ #个值"
echo "value is: [Email protected]"
echo "The third parameter is $ three"
echo "$?" The last command exits the status as 0 normal "
}
Tesfunc a b c d E F


This article is from the "2722951" blog, please be sure to keep this source http://2732951.blog.51cto.com/2722951/1901033

Linux-shell First Lesson

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.