Linux学习-Shell基础-脚本执行方式

  • echo输出命令
    echo 输入的值
    -e 支持反斜线控制的字符转行
Linux学习-Shell基础-脚本执行方式_第1张图片
反斜杠
  • 例子
    echo -e "ab\bc"

  • 第一个脚本


    Linux学习-Shell基础-脚本执行方式_第2张图片
    hello.sh

    1 写完整的注释
    2 shell脚本的注释需要加 上"#!/bin/bash"

  • 脚本执行
    1 赋予执行权限,直接运行--较习惯?

    ls -l hello.sh

    权限原来为,644-755 均增加了x权限
    chmod 755 hello.sh
    ./hello.sh

    可执行程序,必须绝对路径只是或者相对路径执行
    2 通过bash直接调用执行脚本
    bash hello.sh - Linux当中命令是没有大写的


  • 1 cat -A 文件命令 查看所有,包括特殊字符。。
    2 Linux和window中回车符不同
    3 dos2unix hello.sh 将文件中dos的格式换成linux格式
    4 yum -y install dos2unix 安装dos2unix
    5 用shell写,格罗斯方块。

你可能感兴趣的:(Linux学习-Shell基础-脚本执行方式)