Linux环境下编程笔记
- 1.shell脚本的hello wored
- 2.C语言脚本的hello wored
- 3.C语言调用shell命令及脚本
新建一个shell脚本touch hello.sh
通过shell指令执行脚本:
使用chomd 775开放权限或者使用bash直接运行
#!/bin/bash echo "hello world my shell"2.C语言脚本的hello wored
1.新建一个c文件touch hello.c
2.编译:gcc hello.c回车,然后会生成一个名叫a.out 的执行文件
生成指定名字的.out文件gcc hello.c -o hello.out
3.运行:./a.out回车
#include3.C语言调用shell命令及脚本#include //延时函数引用头文件 int main(void) { printf("hello wordn"); sleep(3);//延时函数秒单位 printf("hello wordn"); return 0; }
Linux中C语言执行shell脚本的方法: https://blog.csdn.net/u010299133/article/details/85637263
#include#include //system函数驱动shell命令 #include //延时函数引用头文件 int main(void) { printf("hello wordn"); sleep(3);//延时函数秒单位 printf("hello wordn"); system("bash ./hello2.sh");//执行shell脚本 return 0; }



