← Back to Bash Course | Chapter 1: Setup & Basics | Lesson 7 of 12

Your First Script

In this page:

  1. Your First Script

Your First Script

A complete first script combines the shebang, a few commands, and comments explaining intent. Saving it with a .sh extension is a convention, not a requirement — Bash doesn't care about file extensions. What matters is the shebang line and execute permission.

Note: Keep your first scripts small and test them often rather than writing many commands before running anything.

Example: Your First Script

bash
#!/bin/bash
# My first Bash script
echo "Starting script..."
name="World"
echo "Hello, $name!"
echo "Script finished."

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.