Skip to Content
Learn Linux Shell Scripting - Fundamentals of Bash 4.4
book

Learn Linux Shell Scripting - Fundamentals of Bash 4.4

by Sebastiaan Tammer
December 2018
Beginner
452 pages
12h 17m
English
Packt Publishing
Content preview from Learn Linux Shell Scripting - Fundamentals of Bash 4.4

Chapter 13

  1. In which two ways can we define a function?
    • name() { }
    • function name { }
  2. What are some advantages of functions?
    • Easy to reuse code
    • Facilitates code sharing
    • Abstracting complex code
  3. What is the difference between a globally scoped variable and a locally scoped one? Locally scoped variables are only valid within a function, globally scoped variables can be used throughout the entire script (even in functions).
  4. How can we set values and attributes on variables? By using the declare command.
  5. How can a function use arguments passed to it? In the same way as a script can: by using $1, $#, $@, and so on.
  6. How can we return a value from a function? By outputting it to stdout. The command that calls the function should know to capture ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Bash Scripting Fundamentals

Bash Scripting Fundamentals

Sander van Vugt

Publisher Resources

ISBN: 9781788995597Supplemental Content