Hello.... Friends Today we are going to discus about the functions in the Shell Programming or shell Scripting. as we knows a function have vary important role in any Programming Language. Basically we use the functions to define any specific set of code & that set of code which is defined under functions can be called at another part of programs as we want.
so we can say that any function is a way of arrangements of code in a small part & well manners.
Let's check how to define a function in a shell programming...
How to Define a function :
Basically in shell script function is define by pair of parentheses () or by curly brackets {} just after function name.
for exp.
this is a very simple Demo to define a function here func() is our function & the function is enclosed in curly brackets {} this is the condition we assign, here one this to be understand is if i want the same output at other part of program then now i have to just call the func() now we not need to write the program inside curly brackets {} again & again.
To understand func. let's take more example:
this is our vary simple script which gives us the useful information about our system by using function call, here i am just calling a function mach() & in function i define the various commands
for Machine information and calling this function with mach at the end.
here is the output file which we collect from our above script :)
In this tutorial we just need to understand what is function, how to call it & how to use it in scripts .
thank you ~:) ~:)
so we can say that any function is a way of arrangements of code in a small part & well manners.
Let's check how to define a function in a shell programming...
How to Define a function :
Basically in shell script function is define by pair of parentheses () or by curly brackets {} just after function name.
for exp.
this is a very simple Demo to define a function here func() is our function & the function is enclosed in curly brackets {} this is the condition we assign, here one this to be understand is if i want the same output at other part of program then now i have to just call the func() now we not need to write the program inside curly brackets {} again & again.
To understand func. let's take more example:
this is our vary simple script which gives us the useful information about our system by using function call, here i am just calling a function mach() & in function i define the various commands
for Machine information and calling this function with mach at the end.
here is the output file which we collect from our above script :)
In this tutorial we just need to understand what is function, how to call it & how to use it in scripts .
thank you ~:) ~:)
No comments:
Post a Comment