Linux Shell QuickStart Small example (Shell 13 ask learning note)

Source: Internet
Author: User

Read the CU forum Shell 13 After a few small experiments, prepare to forget!

Shell 13 Q Address: http://bbs.chinaunix.net/thread-218853-1-1.html

#!/bin/bashfunction func_com () {Local a=1 local b= "2c3" Echo ${a}b echo $ab}function Func_arra Y () {echo "##### func_array #####" local path= "/home/stone" source $PATH/include/tt.ini #echo $name Local srand= (1 3 5 2) Local srand_num=${#srand [*]} for ((i=0;i< $srand _num;i++));d o Ech O $ ((srand[i]+age)) done echo "##### func_array #####"}function func_for () {echo "##### func_for # # # # # # # # "Local bin_path="/usr "local array= (2 3 5 7 9) Local array_n=${#array [*]} for dir in $ (LS $b        In_path);        Do echo $dir the Done for ((i=0;i< $array _n;i++)); Do echo ${array[i]} done echo "##### func_for #####"}function Func_getlen () {echo "$#"}functio         n Func_param () {echo "##### Func_len \[email protected] #####" Func_getlen "[email protected]" echo "##### Func_len \[email protected] ##### "echo" ##### func_len \$* ##### "Func_getlen" $* "echo" ##### func_len \$* ##### "}function Func_calc () {echo "##### func_calc \$* #####" local a= $RANDOM local b=4 local c=8 d=$ (        (A+B)) echo $d e= ' expr $a + 7 ' echo $e echo "##### func_calc \$* #####"}function func_exit () {local S        tr1= "ABC" Local Str2= "Def" echo $str 1 Exit 0 echo $str 2}function func_if () {Local a=1        Local b=3 local str= "abc" if [! $a =1];then echo "equal" elif [[$STR = "abc"]]        then echo "str equal" else echo "Else" fi}function Func_read () {  Op= "" While [[$op! = "Q"]] do read-p "input one word ' a,b,q '!" Op case $op                In a) echo "The word is $op";;                b) echo "B";;         Q       exit;;                *) echo "Input err!" Esac done}function func_getopt () {args= "' Getopt-u-o" ht:a:n: "-L" Help,time:,age:,number: "--" [Email&nbs         P;protected] "'" [$?-ne 0] && usage set--${args} while [true];                        Do case $ in-h|--help) usage shift                ;;                -t|--time) echo "Time is $" shift;                -a|--age) echo "Age is $" shift;                -n|--number) echo "number is $" shift;                --) shift break;;        *) usage;;     Esac   Shift Done}main () {func_com #func_for #func_array #func_param 1 a 2 b #func_c ALC #func_exit #func_if #func_read #case while getopt #func_getopt-T 20150320-a 25- -number 88}main


Linux Shell QuickStart Small example (Shell 13 ask learning note)

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.