Parameterized procedure in bash shell.

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

Post a Comment

Previous Post Next Post