Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created August 23, 2022 16:33
Show Gist options
  • Save coderofsalvation/b61ac5e94724630152112dc8f19e08d7 to your computer and use it in GitHub Desktop.
Save coderofsalvation/b61ac5e94724630152112dc8f19e08d7 to your computer and use it in GitHub Desktop.
simple sourcecode preprocessor-file-import-include bundler using awk
#!/bin/sh
awk '/^#include *".*"$/ {
i = index($0, "\"");
file = substr($0, i + 1, length() - i - 1);
while ((getline < file) == 1) print;
close(file);
next;
} 1' myfile.txt > myfile.bundled.txt
other content
hello
#import "foo.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment