A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
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.
#!/bin/bash echo Hello, World!
Hello World in Bash was written by:
If you see anything you'd like to change or update, please consider contributing.
Note: The solution shown above is the current solution in the Sample Programs repository as of May 09 2018 12:47:13. The solution was first committed on May 09 2018 11:32:08. As a result, documentation below may be outdated.
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.
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:
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!