示例脚本及注释


#!/bin/bash
echo "hello shell!" # 打印字符串“hello shell!” echo "Date: " `date` # 显示命令执行结果 echo "\"It is a test!\"" # \ 转义字符
echo '\"It is a test!\"' # 在单引号中原样输出字符串,不进行转义或取变量 echo -e "Pass! \n" # -e 启用反斜线控制字符的转换,\n 显示换行
echo "Pass! \n" # 默认关闭反斜线控制字符的转换 # #! --- 指定解释器
# echo --- display a line of text
# # --- 单行注释,Shell不支持多行注释
#
#
# ### Shell与Shell脚本
# - Shell是提供访问操作系统内核服务界面的应用程序;
# - 通过Shell脚本(shell script)可以在Shell中实现特定功能;
# - 脚本执行时,一边解释一边执行,如果脚本包含错误,只要没执行到这一行,就不会报错;
# - 查看可用shell: cat /etc/shells
# - 查看shell版本: bash --version
#
#
# ### 执行脚本的方法
# 1. 使用chmod命令为脚本文件添加可执行权限,然后直接执行(脚本内需要指定解释器路径)
# 2. 通过“bash test.sh”方式将脚本作为解释器的参数,直接调用解释器
# 3. 使用source命令或"."执行文件,例如“source test.sh”(在父进程中直接执行,不会创建子进程)
#
#
# ### echo命令
# 通过“man echo”获取命令详细信息
# 参数“-E”:关闭反斜线控制字符的转换(默认)
# 参数“-e”:启用反斜线控制字符的转换
# 参数“-n”:取消行末的自动换行

Shell - 简明Shell入门01 - 第一个脚本(HelloShell)的更多相关文章

  1. Shell - 简明Shell入门

    本文以示例和注释的方式,对Shell编程的基本知识点进行了总结和回顾,所有脚本均已做了基本的调试和验证. Shell - 简明Shell入门 01 - 第一个脚本 脚本的定义.执行方法以及echo命令 ...

  2. Shell - 简明Shell编程

    本文是对Shell脚本编程的总结和回顾,所有涉及的脚本均已做了基本的调试和验证. [toc] 测试环境信息 [root@CentOS7 ~]# uname -a Linux CentOS7 3.10. ...

  3. Linux - 简明Shell编程01 - 第一个脚本(HelloShell)

    脚本地址 https://github.com/anliven/L-Shell/tree/master/Shell-Basics 示例脚本及注释 #!/bin/bash echo "hell ...

  4. Shell - 简明Shell入门11 - 调用脚本(CallTheScript)

    示例脚本及注释 主脚本: CallTheScript.sh #!/bin/bash . ./11-subscript.sh # 调用其他脚本;注意点号"."和文件路径之间有一空格; ...

  5. Shell - 简明Shell入门14 - 操作符(Operator)

    示例脚本及注释 #!/bin/bash echo "No code, just some comments." # ### 通配符 # * 代表任意(0个或多个)字符 # ? 代表 ...

  6. Shell - 简明Shell入门13 - 用户输入(UserInput)

    示例脚本及注释 1 - arguments #!/bin/bash if [ -n "$1" ];then # 验证参数是否传入 echo "The first para ...

  7. Shell - 简明Shell入门08 - 函数(Function)

    示例脚本及注释 #!/bin/bash function Check() # 使用function定义函数 { Say # 通过函数名直接调用函数 if test $1 then return 0 # ...

  8. Shell - 简明Shell入门04 - 判断语句(If)

    示例脚本及注释 #!/bin/bash var=$1 # 将脚本的第一个参数赋值给变量var if test $var # test - check file types and compare va ...

  9. Shell - 简明Shell入门02 - 变量(Variable)

    示例脚本及注释 #!/bin/bash v1=test-variable_123 # 全局变量 v2=12345 v3='This is a test!' # 赋值语句使用单引号或双引号可以包含空格 ...

随机推荐

  1. 【转】Centos yum 换源

    [1] 首先备份/etc/yum.repos.d/CentOS-Base.repo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/Cent ...

  2. php,ajax上传文件,多文件上传

    HTML <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF- ...

  3. IE上如何设置input type=file的光标不闪烁

    我们使用文件上传时,时常自定义图标,这时候通常会把input的透明度设置为0,但是在IE上使用时会出现光标闪烁问题 解决办法 css设置font-size为0

  4. BeautifulSoup学习心得(一)

    [BeautifulSoup最简介] BeautifulSoup,是Python中的一个第三方库,用于帮助解析Html/XML等内容,便于实现后期的内容提取等方面的工作. BeautifulSoup官 ...

  5. x11 VNC远程桌面

    Ubuntu远程桌面,类似于qq远程桌面(Ubuntu没有内置桌面系统吗?) $ sudo apt-get update $ sudo apt-get install x11vnc $ x11vnc ...

  6. webService之helloword(java)rs

    webservice之rs(helloworld) 1.pom.xml文件 <dependencies> <!-- 使用CXF RS开发 --> <dependency& ...

  7. (01背包 第k优解) Bone Collector II(hdu 2639)

    http://acm.hdu.edu.cn/showproblem.php?pid=2639       Problem Description The title of this problem i ...

  8. (最大上升子序列)Monkey and Banana -- hdu -- 1069

    http://acm.hdu.edu.cn/showproblem.php?pid=1069      Monkey and Banana Time Limit:1000MS     Memory L ...

  9. 《ARM Cortex-M3权威指南》笔记(1)

    http://blog.csdn.net/roverx/article/details/6624859 第1章 介绍 一.ARM Cortex‐M3处理器初探 CM3处理器内核是单片机的中央处理单元( ...

  10. POJ3616--Milking Time(动态规划)

    Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that sh ...