Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Created September 16, 2021 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/0d00f9afe0c274414220ee73e3a77120 to your computer and use it in GitHub Desktop.
Save Hermann-SW/0d00f9afe0c274414220ee73e3a77120 to your computer and use it in GitHub Desktop.
C++ script with bash part output "hello " and C++ part output "world"
#!/bin/bash
exc=/tmp/`basename $0`
if [ $0 -nt $exc ]; then sed -n "/^\/\*\*$/,\$p" $0 | g++ -x c++ - -o $exc; fi
echo -n "hello "
$exc
exit
/**
*/
#include <iostream>
int main()
{
std::cout << "world" << std::endl;
}
@Hermann-SW
Copy link
Author

$ ./hello_world.cpp 
hello world
$ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment