Linux 学习 之 bash
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
, andexec
) cannot be implemented outside of the shell because they directly manipulate the shell itself. Thehistory
,getopts
,kill
, orpwd
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 ]
- [ -a file ] True if file exists.
- -b file True if file exists and is a block special file.
- -c file True if file exists and is a character special file.
- -d file True if file exists and is a directory.
- -e file True if file exists.
- -f file True if file exists and is a regular file.
- -g file True if file exists and its set-group-id bit is set.
- -h file True if file exists and is a symbolic link.
- -k file True if file exists and its "sticky" bit is set.
- -p file True if file exists and is a named pipe (FIFO).
- -r file True if file exists and is readable.
- -s file True if file exists and has a size greater than zero.
- -t fd True if file descriptor fd is open and refers to a terminal.
- -u file True if file exists and its set-user-id bit is set.
- -w file True if file exists and is writable.
- -x file True if file exists and is executable.
- -G file True if file exists and is owned by the effective group id.
- -L file True if file exists and is a symbolic link.
- -N file True if file exists and has been modified since it was last read.
- -O file True if file exists and is owned by the effective user id.
- -S file True if file exists and is a socket.
- file1 -ef file2 True if file1 and file2 refer to the same device and inode numbers.
- file1 -nt file2 True if file1 is newer (according to modification date) than file2, or if file1 exists and file2 does not.
- file1 -ot file2 True if file1 is older than file2, or if file2 exists and file1 does not.
- -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).
- -v varname True if the shell variable varname is set (has been assigned a value).
- -z string True if the length of string is zero.
- -n string
- string True if the length of string is non-zero.
- string1 == string2
- string1 = string2 True if the strings are equal. ‘=’ should be used with the test command for POSIX conformance.
- string1 != string2 True if the strings are not equal.
- string1 < string2 True if string1 sorts before string2 lexicographically.
- string1 > string2 True if string1 sorts after string2 lexicographically.
- arg1 OP arg2
- 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的更多相关文章
- linux学习12 bash的常见特性及文本查看命令实战
一.回顾 1.FHS,命令及bash命令历史 a.FHS: /bin,/sbin,/lib,/lib64,/etc /home,/root /boot /media,/mnt /proc,/sys / ...
- 鸟哥的Linux学习笔记-bash
1. /bin/bash是linux预设的shell,也是Linux发行版的标准shell,它兼容sh,可以看作是sh的功能加强. 2. bash具有命令记录功能,在bash中通过上下键就可以翻找之前 ...
- Linux学习笔记(15)shell基础之Bash基本功能
1 shell概述 shell是一个命令解释器,为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序.用户可以用shell启动.挂起.停止甚至是编写一些程序. shell是一个功能强大 ...
- Linux 学习记录 四(Bash 和 Shell scirpt)
一.什么是 Shell? 狭义的shell指的是指令列方面的软件,包括基本的Linux操作窗口Bash等,广义的shell则包括 图形接口的软件,因为图形接口其实也可以操作各种驱动程序来呼叫核心进行工 ...
- Linux 学习记录 四(Bash 和 Shell scirpt).
一.什么是 Shell? 狭义的shell指的是指令列方面的软件,包括基本的Linux操作窗口Bash等,广义的shell则包括 图形接口的软件,因为图形接口其实也可以操作各种驱动程序来呼叫核心进行工 ...
- Linux 学习笔记
Linux学习笔记 请切换web视图查看,表格比较大,方法:视图>>web板式视图 博客园不能粘贴图片吗 http://wenku.baidu.com/view/bda1c3067fd53 ...
- 实验楼 linux 学习
实验楼 linux 学习 一.Linux 用户管理 1.查看用户 who am i // who mom likes whoami ====--------====== 输入的第一列表示打 ...
- Linux学习历程(持续更新整理中)
1.文件目录操作命令 (1) ls 显示文件和目录列表 a ls -l 显示文件的详细信息 b ls -a 列出当前目录的所有文件,包含隐藏文件. c stat '目录/文件' 显示指定目录 ...
- Linux学习笔记(一)2015.4.13
研究生由单片机转Linux学习 首先安装VMware虚拟机,用的是VMware 10.0 在VMware 10.0上安装视频上推荐的Red Hat Linux 5 安装后正式进入Linux学习 笔记1 ...
随机推荐
- [ZJOI2008]生日聚会 BZOJ1037 dp
题目描述 今天是hidadz小朋友的生日,她邀请了许多朋友来参加她的生日party. hidadz带着朋友们来到花园中,打算坐成一排玩游戏.为了游戏不至于无聊,就座的方案应满足如下条件: 对于任意连续 ...
- PAT天梯赛L1-054 福到了
题目链接:点击打开链接 "福"字倒着贴,寓意"福到".不论到底算不算民俗,本题且请你编写程序,把各种汉字倒过来输出.这里要处理的每个汉字是由一个 N x N 的 ...
- servlet验证2
登录界面 登录成功后 数据库 地址:https://gitee.com/lgcj1218/j2eehomework/tree/master
- angularJs获取复选框中id 进行批量删除
主要思路:我们需要定义一个用于存储选中 ID 的数组,当我们点击复选框后判断是选择还是取消选择,如果是选择就加到数组中,如果是取消选择就从数组中移除.在点击删除按钮时需要用到这个存储了 ID 的数组. ...
- java 获取 正在执行的方法名
//获取调用该方法的方法名.... String method = Thread.currentThread().getStackTrace()[2].getMethodName(); //获取正在执 ...
- B. Sereja and Suffixes
B. Sereja and Suffixes time limit per test 1 second memory limit per test 256 megabytes input standa ...
- C语言一些易混淆的概念
①数组指针和指针数组 1. 数组指针用于指向一个数组,数组名是数组首元素的地址(数组名为数组首元素类型且指向首元素的指针,如int array[5] ,array为指向array[0]的指针且类型为i ...
- spark Failed to get database default, returning NoSuchObjectException
解决方法:1)Copy winutils.exe from here(https://github.com/steveloughran/winutils/tree/master/hadoop-2.6. ...
- Postman如何做接口测试
Postman 之前是作为Chrome 的一个插件,现在要下载应用才能使用. 以下是postman 的界面: 各个功能区的使用如下: 快捷区: 快捷区提供常用的操作入口,包括运行收藏夹的一组测试数据, ...
- python pd.read_csv/pd.read_table参数详解