zoukankan      html  css  js  c++  java
  • 第一个shell脚本(一)

    第一个脚本

    [root@ipha-dev71-1 exercise_shell]# ll
    total 4
    -rw-r--r-- 1 root root 32 Aug 27 15:24 test.sh
    [root@ipha-dev71-1 exercise_shell]# cat test.sh 
    #!/bin/bash                         # 指定解释器信息, #!/bin/sh 也可以
    echo "hello world!"
    [root@ipha-dev71-1 exercise_shell]# chmod 777 test.sh   # 修改文件权限,使其具有可执行权限
    [root@ipha-dev71-1 exercise_shell]# ll
    total 4
    -rwxrwxrwx 1 root root 32 Aug 27 15:24 test.sh
    [root@ipha-dev71-1 exercise_shell]# ./test.sh    # 运行shell脚本的第一种方式:作为可执行程序。注意,一定要写成 ./test.sh,而不是 test.sh,运行其它二进制的程序也一样,直接写 test.sh,linux 系统会去 PATH 里寻找有没有叫 test.sh 的,而只有 /bin, /sbin, /usr/bin,/usr/sbin 等在 PATH 里,你的当前目录通常不在 PATH 里,所以写成 test.sh 是会找不到命令的,要用 ./test.sh 告诉系统说,就在当前目录找。
    hello world!                                           
    [root@ipha-dev71-1 exercise_shell]# /bin/sh      # 运行shell脚本的第二个方式:作为解释器参数。这种运行方式是直接运行解释器,其参数就是shell脚本的文件名。                                                 
  • 相关阅读:
    Linux命令大全
    Restframework 视图组件与序列号组件的应用.
    Linux常用命令
    数据结构
    MongoDB
    算法
    Flask 语音分析
    Flask Session ,pymysql ,wtforms组件 虚拟virtualenv venv
    Flask 视图,模板,蓝图.
    Flask初识
  • 原文地址:https://www.cnblogs.com/wang-mengmeng/p/11418694.html
Copyright © 2011-2022 走看看