Hello World (bash)

From LiteratePrograms

Jump to: navigation, search
Other implementations: Ada | ALGOL 68 | Alice ML | Amiga E | Applescript | AspectJ | Assembly Intel x86 Linux | Assembly Intel x86 NetBSD | AWK | bash | BASIC | Batch files | C | C, Cairo | C, Xlib | C++ | C# | Delphi | Dylan | E | Eiffel | Erlang | Forth | Fortress | Groovy | Haskell | Hume | IBM PC bootstrap | Inform 7 | Java | Java, Swing | JavaScript | LaTeX | Lisp | Logo | Maple | MATLAB | Mercury | OCaml/F Sharp | occam | Oz | Pascal | Perl | PHP | Pic | PIR | PLI | PostScript | Prolog | Python | Rexx | Ruby | Scala | Scheme | Seed7 | sh | Smalltalk | SQL | SVG | Tcl | Tcl Tk | Visual Basic | Visual Basic .NET | XSL

Hello world in the GNU Bourne-again Shell (bash):

  • The first line tells the operating system how to execute this script;
  • "echo" is a built-in shell command, that writes all arguments to standard output.
<<hello_world.sh>>=
#!/usr/bin/env bash

echo "Hello World!"

This is essentially the same program as Hello World (sh), but invokes a different shell. For a simple program like this, it makes little difference which shell is actually used. However, bash offers a number of features not found in the standard Bourne-shell which are useful for developing more complex scripts.

Download code
Personal tools