--- /dev/null
+#!/bin/bash
+
+main()
+{
+ local file="$1"
+ local dir=$(dirname "$file")
+ local regex="^#include \"\(.*\)\"$"
+
+ local include_files=$(cat "$file" \
+ | grep --only-matching "$regex" \
+ | sed "s/$regex/\1/")
+
+ local include_file=
+ local out=$(cat $file)
+ for include_file in $include_files; do
+ local include_regex="#include \"$include_file\""
+ out=$(echo "$out" \
+ | sed "/$include_regex/r $dir/$include_file" \
+ | sed "/$include_regex/d")
+ done
+
+ echo "$out"
+}
+
+main $*
\ No newline at end of file