Automation, Orchestration, and Scripting
A junior administrator is writing a Bash script and needs a function named backup that archives the directory passed as its first argument. Which definition is syntactically valid in Bash?
Show the answer
Correct answerB. backup() { tar -czf "$1.tgz" "$1"; }
A name followed by () and a brace-enclosed body, with the last command ended by a semicolon, is valid. Omitting the semicolon before the closing brace is the tempting error, because Bash then reads the brace as an argument to tar.