0
0
Bash Scriptingscripting~5 mins

Creating a script file (.sh) in Bash Scripting - Quick Revision & Summary

Choose your learning style9 modes available
Recall & Review
beginner
What is the first line in a bash script file and why is it important?
The first line is called the shebang (e.g., #!/bin/bash). It tells the system which program to use to run the script.
Click to reveal answer
beginner
How do you make a bash script file executable?
Use the command chmod +x filename.sh to give execute permission to the script file.
Click to reveal answer
beginner
What command runs a bash script named myscript.sh in the current directory?
Run the script with ./myscript.sh if it has execute permission.
Click to reveal answer
beginner
Why should you use simple text editors like nano or vim to create a .sh file?
Because they save files as plain text without extra formatting, which is required for scripts to run correctly.
Click to reveal answer
beginner
What does the echo command do in a bash script?
It prints text or variables to the screen, helping you show messages or output.
Click to reveal answer
What does the shebang line #!/bin/bash do in a script?
ARuns the script as root
BSpecifies the script interpreter
CComments out the line
DDeletes the script after running
Which command makes a script file executable?
Aedit script.sh
Brun script.sh
Cchmod +x script.sh
Dopen script.sh
How do you run a script named test.sh in the current folder?
A./test.sh
Bbash test.sh
Crun test.sh
Dopen test.sh
Which editor is best for creating a bash script file?
AExcel
BMicrosoft Word
CPhotoshop
Dnano
What does the command echo "Hello" do in a script?
APrints Hello on the screen
BDeletes Hello
CCreates a file named Hello
DRuns Hello program
Explain the steps to create and run a simple bash script file.
Think about writing, saving, permission, and running.
You got /6 concepts.
    Why is it important to use the shebang line in a bash script?
    It tells the system how to run the script.
    You got /3 concepts.