Hello World in Bash

Published on 09 May 2018 (Updated: 15 May 2023)

Welcome to the Hello World in Bash page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

#!/bin/bash

echo Hello, World!

Hello World in Bash was written by:

This article was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

As we can see, printing "Hello, World!" in Bash is quite simple. All we do is call the echo command to print the string.

As an added note, the shebang (#!) tells the environment how to run the script. In this case, we want to run the script using Bash. But, we can use this same notation for other languages as well:

#!/usr/bin/env python
print("Hello, World!")
#!/usr/bin/env ruby
puts "Hello, World!"
#!/usr/bin/env node
console.log("Hello, World!")

Here, we have Hello World in Python, Ruby, and Node.js, respectively. Each of these scripting languages can leverage the shebang syntax for easy execution in Unix, Linux, and Mac environments.

How to Run the Solution

If we want to run the solution, we can easily leverage an online Bash shell. To use the tool, we just have to drop our solution into the editor and hit run.

Alternatively, if we have a bash shell available, we can easily download the script, navigate to its folder from the command line, and run it:

./hello-world.sh

In fact, even Windows 10 users can leverage Bash. How-To Geek has a nice tutorial on how to use Bash on Windows 10. If that sounds interesting, check it out!