Computer Science, asked by atharv1702, 3 months ago

Write a shell script to demonstrate concept of passing arguments to the
function.​

Answers

Answered by balbaral63
0

Answer:

la quite a bit of a 4otff;E off 65yjc[l GA la pr wow it wow la a la

Answered by mrjoker07
3

# a global variable WELCOME_ROOT=Hello # invoke this function with two arguments: # 1. (FROM_VAR) the name of the greeter # 2. (TO_VAR) the name of the greetee # this function returns a welcoming message get_welcoming_message() { FROM_VAR=$1 TO_VAR=$2 # local variable THE_MESSAGE is used while composing the result; it is not accessible from outside the function local THE_MESSAGE="" THE_MESSAGE="$WELCOME_ROOT to $TO_VAR from $FROM_VAR" THE_MESSAGE="$THE_MESSAGE !!!" # this line provides the output from this function; this output can be captured in a variable by the caller using VAR=$(function param1) echo "$THE_MESSAGE" } GUEST=Joe # invoke function get_welcoming_message with two arguments (Jack and $GUEST) and capture the result in variable WELCOME_MESSAGE WELCOME_MESSAGE=$(get_welcoming_message "Jack" $GUEST) echo "message= $WELCOME_MESSAGE"

Similar questions