Script 21: Function 1
#!/bin/bash
HELLO=Hello
function hello
{
local HELLO=World
echo $HELLO
}
echo $HELLO
hello
echo $HELLO
HELLO=Hello
function hello
{
local HELLO=World
echo $HELLO
}
echo $HELLO
hello
echo $HELLO
Script 22: Function 2
#!/bin/bash
function add()
{
c=`expr $1 + $2`
echo $c
}
add 2 3
function add()
{
c=`expr $1 + $2`
echo $c
}
add 2 3
Script 23: Function 3
#!/bin/bash
function quit {
exit
}
function e {
echo $1 $2 $3
}
e Hello hai df
e World
echo $1
quit
echo foo
Script 24: Function Exit
function quit {
exit
}
function e {
echo $1 $2 $3
}
e Hello hai df
e World
echo $1
quit
echo foo
Script 24: Function Exit
#!/bin/bash
function quit {
exit
}
function hello {
echo Hello!
}
hello
quit
echo foo
Script 25: Function Position
function quit {
exit
}
function hello {
echo Hello!
}
hello
quit
echo foo
Script 25: Function Position
function func
{
echo function having arguments $1 and $2
local sum=$[$1+$2]
echo sum is $sum
}
echo script having arguments $1 $2 $3 $4
func $1 $2
echo
func $3 $4
echo function having arguments $1 and $2
local sum=$[$1+$2]
echo sum is $sum
}
echo script having arguments $1 $2 $3 $4
func $1 $2
echo
func $3 $4
No comments :
Post a Comment