Automation, Orchestration, and Scripting

A script defines the function cleanup_logs and then runs bash -c 'cleanup_logs'. The child shell reports "command not found". Which action makes the function available to the child shell?

Show the answer

Correct answerC. Run export -f cleanup_logs before starting the child shell

The export -f option places a function in the environment so child Bash shells inherit it. Plain export applies to variables, not functions, which is why it is the tempting but ineffective choice.