0
0
Bash Scriptingscripting~5 mins

First Bash script in Bash Scripting - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the first line in a Bash script that tells the system which interpreter to use?
The first line is called the shebang. It looks like #!/bin/bash and tells the system to use the Bash shell to run the script.
Click to reveal answer
beginner
How do you make a Bash script executable?
Use the command chmod +x scriptname.sh to give execute permission to your script.
Click to reveal answer
beginner
What command runs a Bash script named hello.sh in the current directory?
Run the script with ./hello.sh if it has execute permission.
Click to reveal answer
beginner
What does this simple Bash script do?
#!/bin/bash
echo "Hello, world!"
It prints the text Hello, world! to the screen.
Click to reveal answer
beginner
Why is it important to save your Bash script with a .sh extension?
The .sh extension helps you and others recognize the file as a shell script, but it is not required for execution.
Click to reveal answer
What does the shebang line #!/bin/bash do in a Bash script?
AComments out the line
BSpecifies the script interpreter
CRuns the script automatically
DDefines a variable
Which command makes a Bash script executable?
Achmod +x script.sh
Brun script.sh
Cbash script.sh
Dedit script.sh
How do you run a Bash script named myscript.sh in the current folder?
Amyscript.sh
Bexecute myscript.sh
Cbash run myscript.sh
D./myscript.sh
What does the command echo "Hello" do in a Bash script?
ADeletes Hello
BCreates a file named Hello
CPrints Hello to the screen
DRuns a program called Hello
Is the .sh extension required to run a Bash script?
ANo, but it helps identify the file
BYes, it is required
COnly on Windows
DOnly if the script is large
Describe the steps to create and run your first Bash script.
Think about writing, saving, permission, and running.
You got /6 concepts.
    Explain the purpose of the shebang line in a Bash script and what happens if it is missing.
    Focus on interpreter selection and script execution.
    You got /4 concepts.