What happens when you run ./report.sh

A user types ./report.sh at a Bash prompt. The file is executable and begins with the line #!/bin/bash. Put the stages of running the script in the order they happen, from pressing Enter to the status being available to the user.

  1. 1.

    The new Bash process reads and runs the script's commands one at a time.

  2. 2.

    The script's last command finishes, and its status becomes the script's exit status.

  3. 3.

    The interactive shell creates a child process to run the command.

  4. 4.

    The interactive shell stores the script's exit status in the special parameter $?.

  5. 5.

    The kernel reads the #! line and starts /bin/bash with the script's path as an argument.

  6. 6.

    The kernel checks that the file has execute permission for the user.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Bash Scripts Questions: