Automation, Orchestration, and Scripting

A function builds a report filename from the current date, and the calling script must store that string in a variable. Which approach correctly passes the string back to the caller?

Show the answer

Correct answerC. Print the filename with echo and capture it with command substitution

A function writes its result to standard output, and the caller captures it with $(function_name). Using return is the tempting choice, but it only accepts an integer from 0 to 255 as an exit status, so it cannot carry a string.