Description #
Bash (Bourne Again SHell) is a Unix shell and command language widely used for automating tasks, managing files, executing scripts, and controlling system processes. It is the default shell on most Linux distributions and macOS systems, making it essential for system administrators, DevOps engineers, and developers.
History #
Bash was developed by Brian Fox for the GNU Project and first released in 1989 as a free software replacement for the original Bourne shell (sh
). It was designed to be POSIX-compliant while including useful features from KornShell (ksh) and C shell (csh).
Bash became the default shell on most Unix-like systems, including Linux and macOS (until replaced by Zsh in macOS Catalina). It remains foundational in scripting, automation, and shell-based programming.
Hello World Code #
#!/bin/bash
echo "Hello, World!"
How to Run #
Save the code to a file named hello.sh
Make it executable:
chmod +x hello.sh
Run it:
./hello.sh
π Alternatively, run directly with:
bash hello.sh
Key Concepts #
#!/bin/bash
β shebang line that defines the interpreter
echo
β prints text to the terminal
Shell scripting β automates command sequences
Environment variables β store reusable values
Conditionals β if
, else
, elif
Loops β for
, while
, until
Command substitution β using $(...)
Exit codes β represent script success or failure
Permissions β execution rights via chmod
Glob patterns β for filename matching (e.g., *.txt
)
Try It Online #
π Tutorialspoint Bash Compiler
π JDoodle β Bash
π Replit β Bash
Fun Facts #
Bash is installed by default on virtually every Linux system
The name βBourne Againβ is a play on the Bourne Shell (sh
)
Bash scripts are used for server startup, build pipelines, and automation
macOS switched to Zsh as the default shell in 2019, but Bash is still included
You can write entire applications using just Bash