AnyCompiler

Your First Bash Script

A Bash script usually starts with a shebang line, #!/bin/bash, which tells the system which interpreter should run the file. Every line after that runs directly, top to bottom, the moment the script starts — there's no separate compile step the way there is in a compiled language, and no main function to define first.

Comments

Comments start with # and run to the end of the line, exactly like Python. They exist purely so humans reading the script later understand why something is written the way it is — Bash itself ignores them completely.

Run it yourself

Here's a small script with a shebang, a comment, and two echo calls. This was actually executed to get the output shown below — try changing the text and running it yourself using the button under the example.

#!/bin/bash
# This is a comment -- ignored by Bash
echo "Hello, world!"
echo "Learning Bash one step at a time."
Output
Hello, world!
Learning Bash one step at a time.

Next: variables — assignment syntax, and a real mistake that trips up every Bash beginner at least once.

Practice exercise

Add a comment above the echo line describing what the script does (the comment itself produces no output), then print exactly: Learning Bash one step at a time.