#!/bin/bash
# This is a comment
# Script: hello-world.sh
# Purpose: Demonstrate basic script structure
echo "Hello, World!"
echo "This is my first shell script"
#!/bin/bash - Tells system which interpreter to use#!/bin/bash - Bash shell#!/bin/sh - POSIX shell (more portable)#!/usr/bin/env bash - Find bash in PATH# Create script file
nano hello-world.sh
# Make executable
chmod +x hello-world.sh
# Run script
./hello-world.sh
# Or run without making executable
bash hello-world.sh
# Run from current directory
./script.sh
# Make available system-wide
sudo cp script.sh /usr/local/bin/
sudo chmod +x /usr/local/bin/script.sh
# Now can run from anywhere
script.sh
Next: → Comments And Documentation
Previous: ← Introduction To Shell Scripting
Lesson Home: ↑ Lesson 8: Scripting
Course Home: ⌂ Introduction to Linux