Create a "Hello, World!" program

Create a "Hello, World!" program

Create a "Hello, World!" program as a simple shell script. It will print a greeting for the name you provide as a command argument (or default to "World").

hello.sh
#!/bin/sh

NAME=${1:-World}
echo "Hello, $NAME!"

Make it executable and confirm that it works as expected.

$ chmod +x hello.sh
$ ./hello.sh

Output:

Hello, world!

Last updated