p12.sh
#!/bin/bash
fun () {
echo $1 //will print orange
echo $2 $1 //will print apple orange
echo $2 //will print apple
}
fun orange apple //passed 2 parameters - orange and apple
output:
:chmod 755 p12.sh
:./p12.sh
orange
apple orange
apple
#!/bin/bash
fun () {
echo $1 //will print orange
echo $2 $1 //will print apple orange
echo $2 //will print apple
}
fun orange apple //passed 2 parameters - orange and apple
output:
:chmod 755 p12.sh
:./p12.sh
orange
apple orange
apple
Tags:
bash scripting
linux
parameterized procedure in shell
procedure in bash
procedure in shell
shell scripting