Multiple choice technology operating systems

I have a script named test.sh and the contents are as follows: \$ cat test.sh echo hi rm -f test.sh echo hi ######## What will be the output of the following comand: \$ sh test.sh

  1. the first 'hi' will be displayed but it will say "Could not delete file: in use" and will exit the script

  2. the first 'hi' will be displayed but it will say "Could not delete file: in use" and will then echo the second 'hi'

  3. The script will display 2 'hi' and the file will also be deleted

  4. The first 'hi' will be displayed, the script will be deleted , but the 2nd 'hi' will not be displayed.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

When running a script with 'sh test.sh', the shell reads the entire file into memory before executing it. This means the script can safely delete itself during execution without affecting its ability to complete. Both echo statements will execute successfully, and the file will be removed.