Chapter 9 Challenges

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← Recursive functionHome[[| →]]
  • Decide whether the following sentence is true or false:
  1. The function file does not need to be executable.
  2. The function is treated the same as other shell command.
  3. To invoke the function, just type the name of the function.
  4. You must create a function at the start of a script.
  5. You must write a function before invoking it.
  6. All single line function must follow the final command with a semicolon.
  7. A recursive function is a function that repeatedly calls itself.
  8. The return command return from a function with an exit status.
  9. The { list; } also creates a function. ( [ $# -eq 0 ] && { echo "I'm function"; exit 1; } )
  10. Bash does support pointer arithmetic, and indirect referencing just like C programs.
  • Create user-defined functions in a shell script for the following tasks:
  1. add_user() - Add a user to the system.
  2. add_group() - Add a group to the system.
  3. change_password() - Change user password.
  4. delete_user() - Remove a user from the system.
← Recursive functionHome[[| →]]