C脚本

http://rosettacode.org/wiki/Multiline_shebang#C
https://news.ycombinator.com/item?id=9144467

在网上看到把C语言当成脚本的方法,很有意思的技巧,需要预装make命令
root@kali:~# cat a.c
//usr/bin/make -s "${0%.c}" && ./"${0%.c}" "$@"; s=$?; rm ./"${0%.c}"; exit $s
#include <stdio.h>
int main(int argc, char** argv){
printf("%s\n", "Hello World");
return 0;
}


root@kali:~# chmod 777 ./a.c
root@kali:~# ./a.c
Hello World

//usr/bin/make -s "${0%.*}" && ./"${0%.*}" "$@"; s=$?; rm ./"${0%.*}"; exit $s
#include <stdio.h>
int main(int argc, char** argv){
printf("%s\n", "Hello World");
return 0;
}


你可能感兴趣的:(脚本)