Produce?

After issuing:

function myfunction { echo $1 $2 ; }

in Bash, which output does:

myfunction A B C

Produce?
A . AB
B . ABC
C . AC
D . BC
E . CBA

Answer: A

Explanation:

In Bash, a function is a block of code that can be invoked by its name. A function can take arguments, which are passed to the function as positional parameters. The $1 variable refers to the first argument, $2 to the second argument, and so on. The function can access the number of arguments passed to it by using the $# variable. In this case, the function myfunction simply echoes the first and second arguments to the standard output. Therefore, when the command myfunction A B C is executed, the output is A B, since the third argument C is ignored by the function.

Reference: [LPI Linux Essentials – Topic 103: Command Line Basics]

[Bash Functions]

Latest 102-500 Dumps Valid Version with 194 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments