Scripting ‘Hello World’
If you’ve never written a shell script before, this is the place to start. If you have, maybe skip this as it covers the absolute basics.
Writing a “Hello World” program is a rite-of-passage in the programming world. Here is how to do it in shell scripting (via the command line in an enterprise-grade Linux system).
Assumption: You already know how you use
vim
.
- Starting from the command line, create a new file called “HelloWorld.sh” using
vim
:
vim HelloWorld.sh
- Inside “HelloWorld.sh”, write the following:
#!/bin/bash
echo "Hello World!"
Save the file and exit using
:wq
Make the file executable by issuing the command
chmod 700 HelloWorld.sh
(see Basic Permissions for a more thorough explanation).Run your file with
./HelloWorld.sh
: