linux

Linux中环境变量与文件查找

2019-02-25  本文已影响5人  CurryCoder

一、环境变量

#! /bin/bash
for((i=0;i<10;i++)); do
  echo "hello shell"
done
exit 0

为文件添加执行权限:
chmod 755 hello_shell.sh
执行脚本:
./hello_shell.sh
创建一个C语言程序:
vim hello_world.c
添加C文件:

#include <stdio.h>
int main(void){
        printf("hello word!\n");
    return 0;
}

使用gcc生成可执行文件:
gcc -o hello_world hello_world.c
gcc生成二进制文件默认具有可执行权限,无需修改。在cdl目录中创建mybin目录,将上述文件移动到其中:
mkdir mybin
mv hello_shell.sh hello_world mybin/
此时,可在mybin目录下运行刚刚创建的程序:
cd mybin
./hello_shell.sh
./hello_world

二、搜索文件(与搜索文件相关的命令常用的有whereis which find locate)

上一篇 下一篇

猜你喜欢

热点阅读