How to execute bash commands from C? [duplicate]
Use system()
:
#include <stdlib.h>int status = system("gzip foo");
See the man page (man 3 system
) for more detailed information on how to use it.
By the way, this question already has an answer here: How do I execute external program within C code in linux with arguments?