Powerful File Inclusion for Bash

1 min read Original article ↗

Lightweight & Recursive

A simple yet powerful Bash utility to include file contents using a tag system. Build complex text documents from reusable snippets effortlessly.

Why use include.sh?

Powerful features packed into a single shell script.

File Inclusion

Replace ~>> filename <<~ with actual content instantly.

Recursive

Include files that include other files. Deeply nested templates made easy.

Flexible Output

Stream directly to stdout or specify a target file as a second argument.

Safe Handling

Robust error messages when files are missing to ensure your build doesn't fail silently.

See it in action

Imagine you have a world.txt containing "World" and a hello.txt using the tag system. Running the script merges them perfectly.

Simple syntax: ~>> file <<~

Supports standard piping and redirection

Zero dependencies besides standard Unix tools

Requirements

Installation

Step 1

# Download the script

curl -L https://include-sh.codeberg.page/include.sh -o include.sh

Step 2

# Make executable

chmod +x include.sh

Step 3

# Move to PATH and rename

sudo cp include.sh /usr/local/bin/include
sudo chmod +x /usr/local/bin/include

Ready to go!

Now that it's installed, you can run the include command from anywhere in your terminal.

include hello.txt

include hello.txt > output.txt

include hello.txt output.txt