Bird
0
0

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:
  1. Step 1: Recall bash function syntax

    Bash functions are defined as name() { commands; } or function name { commands; }.
  2. 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.
  3. Final Answer:

    backup() { commands; } -> Option C
  4. Quick Check:

    Bash function syntax = A [OK]
Quick Trick: Use name() { commands; } to define bash functions [OK]
Common Mistakes:
MISTAKES
  • Using Python or other language syntax
  • Omitting parentheses in function name
  • Using := which is invalid in bash

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes