Application examples of shell programming functions

Source: Internet
Author: User

Write a script:

1, create a function, you can accept the Inode or block two parameters, if the user passed other parameters, then return error message 53 to the main program;

If the parameter passed is an inode, the usage of all the file system Inode nodes on the current system is displayed;

If the parameter passed is block, the use of all file system blocks on the current system is displayed;

2, call this function;

The code is as follows:

#!/bin/bash  
#Author: MOS  
#Script name:funDinfo.sh  
#Date & time:2012-10-09/21:44:16  
#Version: 1.0.1  
#Description:  
#  
#定义函数Disk_  
disk_ () {  
#case语句选择 case into
inode)  
    df-iph;;  #显示inode信息, the following is block block  
)  
    DF-PBH;  
*) return  
    #如果输入不符合, End Function, pass value  
Esac  
}  
#给出信息, read parameter  
read-p "Please input [Inode|block]:" Info  
#调用参数  
disk_ $Info  
#获取函数返回值, judging, if equal, output the following information  
[$-eq] && echo "Input error, error num ber is 53 "

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.