Linux Foundation Certified System Administrator Exam: Bash Scripting | myfunction Output | Linux

myfunction Output: A B

Question

After issuing:

function myfunction { echo $1 $2 ; }

in Bash, which output does:

myfunction A B C

Produce?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

A

The function myfunction is defined as taking two arguments, and echoing them out with a space in between. When the command myfunction A B C is executed in the shell, "A" is passed as the first argument ($1) and "B" as the second argument ($2). The third argument "C" is ignored as it is not used in the function.

Therefore, the output of myfunction A B C will be:

css
A B

This matches answer A.