Which is the correct syntax to define a function named backup in bash?
easy📝 Syntax Q3 of 15
Bash Scripting - Functions
Which is the correct syntax to define a function named backup in bash?
Adef backup() { commands }
Bfunction backup{ commands }
Cbackup() { commands; }
Dbackup := { commands }
Step-by-Step Solution
Solution:
Step 1: Recall bash function syntax
Bash functions are defined as name() { commands; } or function name { commands; }.
Step 2: Evaluate options
backup() { commands; } uses the standard syntax with parentheses and braces. function backup { commands } misses parentheses, C uses Python style, D uses invalid syntax.