Reading — step 1 of 5
Learn
Hello, World
Bash is not like the other languages on this platform, and pretending otherwise is how people get hurt. It's a command interpreter that grew into a language: its "statements" are programs, its "values" are text, and its syntax rules were accreted over fifty years of staying compatible with 1970s terminals. Learn it on its own terms and it becomes the highest-leverage tool you own — every server, container, and CI pipeline speaks it.
The script
#!/usr/bin/env bash
echo "Hello, World"
- Line 1 is the shebang —
#!followed by an interpreter. When you execute the file, the kernel (yes, the actual OS kernel — see the OS course) reads these bytes and runs the named program with your file as input./usr/bin/env bashmeans "find bash wherever it lives" — more portable than hardcoding/bin/bash. echoprints its arguments and a newline. Here's the mental shift:echoisn't a keyword — it's a command, the same species aslsorgit. A bash script is a list of command invocations with control flow around them.
Run it:
$ bash hello.sh # explicit interpreter
$ chmod +x hello.sh # or: mark executable (once)…
$ ./hello.sh # …and run directly (shebang kicks in)
Hello, World
chmod +x sets the executable permission bit — the reason the own-editor starter's run_tests.sh "just runs."
Words, the unit of everything
Bash parses every line into words separated by whitespace — command first, then arguments. This is the central fact of the language, and it's why quoting (next lessons) matters more in bash than anywhere else:
echo Hello, World # TWO arguments: "Hello," and "World" — echo joins with a space
echo "Hello, World" # ONE argument. Same output here… pure luck.
Those print identically, which teaches the wrong lesson. Try echo Hello, World (multiple spaces — collapsed, because they were just word separators) and the difference surfaces. The habit that will save you a hundred times in this course: when the text matters, quote it.
Comments run from # to end of line — same as Python.
What bash is for (and not for)
Fair warning about the tool you're learning: bash is unbeatable for gluing programs together — run this, filter through that, retry on failure, across every Unix machine alive with zero dependencies. It is miserable for data structures, arithmetic-heavy logic, and 500-line programs (that's when you graduate a script to Python or Go). The rule of thumb the industry converged on: if a bash script outgrows a screen or two, it wanted to be a real program. This course teaches you the screenful — properly, safely, idiomatically — which is precisely the part everyone actually uses forever.
Your exercise
Print the exact text. Graders are byte-exact: echo "Hello, World" emits the string and one newline — done. Note there's no compile step and no main; the script is the program, executed top to bottom, and its exit status (a concept with its own lesson later) is that of its last command. Welcome to the glue layer of computing.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…