Linux下创建shell、C小程序介绍

1.创建一个shell脚本文件

gedit hello_shell.sh ##创建文件

2.###在文件内添加一下内容

#!/bin/bash

for ((i=0;i<10;i++));do

  echo "hello shell"

done

exit 0

3.为文件添加可执行权限

chmod 755 hello_shell.sh

4.执行脚本

./hello_shell.sh

###创建一个C语言程序"hello world"

1.gedit hello_world.c

2.##添加一下内容

#include <stdio.h>

int main(void)

{

  printf("hello world!\n");

  return 0;

}

3.保存后使用gcc生成可执行文件

gcc -o hello_world hello_world.c

gcc生成的二进制文件,默认具有可执行权限,不需要修改