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. [ZJOI2008]生日聚会 BZOJ1037 dp

    题目描述 今天是hidadz小朋友的生日,她邀请了许多朋友来参加她的生日party. hidadz带着朋友们来到花园中,打算坐成一排玩游戏.为了游戏不至于无聊,就座的方案应满足如下条件: 对于任意连续 ...

  2. PAT天梯赛L1-054 福到了

    题目链接:点击打开链接 "福"字倒着贴,寓意"福到".不论到底算不算民俗,本题且请你编写程序,把各种汉字倒过来输出.这里要处理的每个汉字是由一个 N x N 的 ...

  3. servlet验证2

    登录界面 登录成功后 数据库 地址:https://gitee.com/lgcj1218/j2eehomework/tree/master

  4. angularJs获取复选框中id 进行批量删除

    主要思路:我们需要定义一个用于存储选中 ID 的数组,当我们点击复选框后判断是选择还是取消选择,如果是选择就加到数组中,如果是取消选择就从数组中移除.在点击删除按钮时需要用到这个存储了 ID 的数组. ...

  5. java 获取 正在执行的方法名

    //获取调用该方法的方法名.... String method = Thread.currentThread().getStackTrace()[2].getMethodName(); //获取正在执 ...

  6. B. Sereja and Suffixes

    B. Sereja and Suffixes time limit per test 1 second memory limit per test 256 megabytes input standa ...

  7. C语言一些易混淆的概念

    ①数组指针和指针数组 1. 数组指针用于指向一个数组,数组名是数组首元素的地址(数组名为数组首元素类型且指向首元素的指针,如int array[5] ,array为指向array[0]的指针且类型为i ...

  8. spark Failed to get database default, returning NoSuchObjectException

    解决方法:1)Copy winutils.exe from here(https://github.com/steveloughran/winutils/tree/master/hadoop-2.6. ...

  9. Postman如何做接口测试

    Postman 之前是作为Chrome 的一个插件,现在要下载应用才能使用. 以下是postman 的界面: 各个功能区的使用如下: 快捷区: 快捷区提供常用的操作入口,包括运行收藏夹的一组测试数据, ...

  10. python pd.read_csv/pd.read_table参数详解