Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created July 1, 2011 12:39
Show Gist options
  • Save mlafeldt/1058462 to your computer and use it in GitHub Desktop.
Save mlafeldt/1058462 to your computer and use it in GitHub Desktop.
One-line header enabling executable single-file C scripts (via @reddit)
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
// Usage: bash ./hello.c
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello world!\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment