Anything is programmable with defined syntax and common lib.

Bash Shell is created to programme to Linux command in defined grammar

  • Linux 中的bash shell 拥有自己的一些语法,通过语法我们可以对命令进行编程,也就是脚本编写。脚本就是用一些特定的语法把要执行的命令联合起来自动执行。参考:http://wenku.baidu.com/view/e034565bbe23482fb4da4ce8.html  &  http://www.cnblogs.com/zemliu/archive/2012/05/13/2497784.html
  • What is a shell?

    At its base, a shell is simply a macro processor that executes commands. The term macro processor means functionality where text and symbols are expanded to create larger expressions.

    A Unix shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface to the rich set of GNU utilities. The programming language features allow these utilities to be combined. Files containing commands can be created, and become commands themselves. These new commands have the same status as system commands in directories such as/bin, allowing users or groups to establish custom environments to automate their common tasks.

    Shells may be used interactively or non-interactively. In interactive mode, they accept input typed from the keyboard. When executing non-interactively, shells execute commands read from a file.

    A shell allows execution of GNU commands, both synchronously and asynchronously. The shell waits for synchronous commands to complete before accepting more input; asynchronous commands continue to execute in parallel with the shell while it reads and executes additional commands. The redirection constructs permit fine-grained control of the input and output of those commands. Moreover, the shell allows control over the contents of commands’ environments.

    Shells also provide a small set of built-in commands (builtins) implementing functionality impossible or inconvenient to obtain via separate utilities. For example, cd, break, continue, and exec) cannot be implemented outside of the shell because they directly manipulate the shell itself. The history, getopts, kill, or pwd builtins, among others, could be implemented in separate utilities, but they are more convenient to use as builtin commands. All of the shell builtins are described in subsequent sections.

    While executing commands is essential, most of the power (and complexity) of shells is due to their embedded programming languages. Like any high-level language, the shell provides variables, flow control constructs, quoting, and functions.

    Shells offer features geared specifically for interactive use rather than to augment the programming language. These interactive features include job control, command line editing, command history and aliases. Each of these features is described in this manual.

  • bash shell reference: http://www.gnu.org/software/bash/manual/bash.html
  • bash shell 都有什么命令呢

  • how use these bash shell command? type help command-name

  • 赋值语句: var=value;变量解析: ${var}; 命令解析: $(command) = `command`;双引号" " : 变量内容,并做转义;单引号' ' : 变量内容,但不做转义;反单引号` ` : 同 $()

  • we can get all environment variable by command `env`

  • if shell command

  • Bash Conditional Expressions: The fromat is  [ -option file ], Note the space after [ and before ]
    1. [ -a file ]    True if file exists.
    2. -b file    True if file exists and is a block special file.
    3. -c file    True if file exists and is a character special file.
    4. -d file    True if file exists and is a directory.
    5. -e file    True if file exists.
    6. -f file    True if file exists and is a regular file.
    7. -g file    True if file exists and its set-group-id bit is set.
    8. -h file    True if file exists and is a symbolic link.
    9. -k file    True if file exists and its "sticky" bit is set.
    10. -p file    True if file exists and is a named pipe (FIFO).
    11. -r file    True if file exists and is readable.
    12. -s file    True if file exists and has a size greater than zero.
    13. -t fd      True if file descriptor fd is open and refers to a terminal.
    14. -u file    True if file exists and its set-user-id bit is set.
    15. -w file    True if file exists and is writable.
    16. -x file    True if file exists and is executable.
    17. -G file    True if file exists and is owned by the effective group id.
    18. -L file    True if file exists and is a symbolic link.
    19. -N file    True if file exists and has been modified since it was last read.
    20. -O file    True if file exists and is owned by the effective user id.
    21. -S file    True if file exists and is a socket.
    22. file1 -ef file2    True if file1 and file2 refer to the same device and inode numbers.
    23. file1 -nt file2    True if file1 is newer (according to modification date) than file2, or if file1 exists and file2 does not.
    24. file1 -ot file2    True if file1 is older than file2, or if file2 exists and file1 does not.
    25. -o optname         True if the shell option optname is enabled. The list of options appears in the description of the -o option to the set builtin (see The Set Builtin).
    26. -v varname         True if the shell variable varname is set (has been assigned a value).
    27. -z string    True if the length of string is zero.
    28. -n string
    29. string    True if the length of string is non-zero.
    30. string1 == string2
    31. string1 = string2    True if the strings are equal. ‘=’ should be used with the test command for POSIX conformance.
    32. string1 != string2   True if the strings are not equal.
    33. string1 < string2    True if string1 sorts before string2 lexicographically.
    34. string1 > string2    True if string1 sorts after string2 lexicographically.
    35. arg1 OP arg2
    36. OP is one of ‘-eq’, ‘-ne’, ‘-lt’, ‘-le’, ‘-gt’, or ‘-ge’. These arithmetic binary operators return true if arg1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to arg2, respectively. Arg1 and arg2 may be positive or negative integers.

Linux 学习 之 bash的更多相关文章

  1. linux学习12 bash的常见特性及文本查看命令实战

    一.回顾 1.FHS,命令及bash命令历史 a.FHS: /bin,/sbin,/lib,/lib64,/etc /home,/root /boot /media,/mnt /proc,/sys / ...

  2. 鸟哥的Linux学习笔记-bash

    1. /bin/bash是linux预设的shell,也是Linux发行版的标准shell,它兼容sh,可以看作是sh的功能加强. 2. bash具有命令记录功能,在bash中通过上下键就可以翻找之前 ...

  3. Linux学习笔记(15)shell基础之Bash基本功能

    1 shell概述 shell是一个命令解释器,为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序.用户可以用shell启动.挂起.停止甚至是编写一些程序. shell是一个功能强大 ...

  4. Linux 学习记录 四(Bash 和 Shell scirpt)

    一.什么是 Shell? 狭义的shell指的是指令列方面的软件,包括基本的Linux操作窗口Bash等,广义的shell则包括 图形接口的软件,因为图形接口其实也可以操作各种驱动程序来呼叫核心进行工 ...

  5. Linux 学习记录 四(Bash 和 Shell scirpt).

    一.什么是 Shell? 狭义的shell指的是指令列方面的软件,包括基本的Linux操作窗口Bash等,广义的shell则包括 图形接口的软件,因为图形接口其实也可以操作各种驱动程序来呼叫核心进行工 ...

  6. Linux 学习笔记

    Linux学习笔记 请切换web视图查看,表格比较大,方法:视图>>web板式视图 博客园不能粘贴图片吗 http://wenku.baidu.com/view/bda1c3067fd53 ...

  7. 实验楼 linux 学习

    实验楼 linux 学习     一.Linux 用户管理 1.查看用户 who am i // who mom likes whoami   ====--------====== 输入的第一列表示打 ...

  8. Linux学习历程(持续更新整理中)

    1.文件目录操作命令 (1) ls   显示文件和目录列表 a ls -l  显示文件的详细信息 b ls -a 列出当前目录的所有文件,包含隐藏文件. c stat '目录/文件'   显示指定目录 ...

  9. Linux学习笔记(一)2015.4.13

    研究生由单片机转Linux学习 首先安装VMware虚拟机,用的是VMware 10.0 在VMware 10.0上安装视频上推荐的Red Hat Linux 5 安装后正式进入Linux学习 笔记1 ...

随机推荐

  1. 使用gifplayer操作gif的方法

    使用的工具--gifplayer 基本用法: 1.安装 git clone https://github.com/rubentd/gifplayer.git 2.添加一张gif预览的图片 <im ...

  2. WebForm与MVC混用 (转)

    http://blog.csdn.net/leftfist/article/details/11591231

  3. 统计元音(stringstream的-应用)

    Problem Description 统计每个元音字母在字符串中出现的次数.   Input 输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串.   Output ...

  4. CSS(九)元素隐藏和利弊

    隐藏元素.无法点击,这之间有什么关系呢? 可以配合我写的 html 食用:https://github.com/dirstart/ScriptOJ/blob/master/OJ_CSS/4.css%E ...

  5. C语言中变量、全局变量与变量的作用域

    什么是变量: 变量常量都是表征数据的一种形式:常量用来表示数据的值: 变量不仅可以用来表示数据的值:还可以用来存放数据:因为变量对应着一定的内存单元: 变量和常量必须先定义后使用. 变量名和常量名都是 ...

  6. svg图转canvas,完全阔以的

    遇到的问题:页面中存在svg画的图,也存在canvas图,在用 html2canvas 截取页面的图就导致有图画缺失,至少我需要的缺失了. 一.如果页面单纯的存在一个svg画的图,转为canvas就很 ...

  7. Sqlite和mysql的区别及优缺点

    小型嵌入式,跟mysql差不多,但更小,功能也少,属于本地数据库多用于读多写少,100W以下的数据压力不大,不支持分布式.   真正开源的小型嵌入式数据库,支持事务.触发器器  性能至少优于mysql ...

  8. thinkphp5 composer安装验证码

    1,安装composer,选择安装到的php的版本.在使用phpstudy的时候 用的是php5.5 .注意phpstudy的安装路径. 2.检查composer是否安装成功.cmd 然后输入comp ...

  9. webAPI过滤器添加参数签名

    项目需求: 接口对安卓和IOS开发接口,需要房子用户窜改数据请求接口.添加sign签名校验参数. 代码如下:加上特性标签就可以控制部分接口验证 public class SignAuthorizeFi ...

  10. linux查找重复文件

    >/dev/ >/dev/null|grep 02a42c7a845094a8904f7b3faf686b81 uniq -d, --repeated only print duplica ...