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.

最新文章

  1. navigationController 的返回按钮自定义
  2. 解决:IOError: [Errno 28] No space left on device(设备空间不足)
  3. 转:MyBean简介
  4. Erlang 104 OTP
  5. C#创建datatable
  6. C# WinForm动态添加MSChart控件
  7. 国内外常用的DNS服务器
  8. Volatile总结
  9. [Android] 输入系统(一)
  10. Python蜕变-2017-4-23
  11. https 协议下服务器根据网络地址下载上传文件问题
  12. 用ECMAScript4 ( ActionScript3) 实现Unity的热更新 -- 操作符重载和隐式类型转换
  13. 最详细的Windows平台安装MongoDB教程
  14. Python第9天
  15. 【php增删改查实例】第十五节 - 用户管理模块(删除确认)
  16. Mysql压缩包版的安装方法详解
  17. linux 查看 cpu个数 核心数 线程数
  18. 互联网公司GitHub repo 语言使用情况
  19. angularJS1笔记-(6)-自定义过滤器
  20. How do I commit all deleted files in Git?

热门文章

  1. [CEOI2008]order BZOJ1391 网络流
  2. 如何进bat
  3. POJ1057 FILE MAPPING
  4. Vscode 隐藏 工作区中的目录
  5. vscode 配置 java utf-8 编码
  6. kibana启动调试
  7. NAS与SAN RAID
  8. 利用Shell脚本实现远程MySQL自动查询
  9. Appium自动化—浅谈iOS自动化测试环境搭建
  10. java web关于文件上传下载的总结