🎴 Flashcard Mode
Unix/Linux Operating System Commands
Card1 / 14
Mastered0
Review0
QuestionClick to flip
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
AnswerClick to flip back
A
The script will display 2 'hi' and the file will also be deleted
💡 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.