文件名称:
BashPragramming.pdf
开发工具:
文件大小: 692kb
下载次数: 0
上传时间: 2019-10-07
详细说明:Bash脚本学习宝典,简单易懂,章节丰富,包含基本bash知识,适合快速上手Bash overview
BASH is an acronym for Bourne-Again SHell, punning on
the name of the bourne shell that it replaces and on the
term born again"that denotes spiritual rebirth in
contemporary american Christianity
Bash is a Unix shell and command language written by
Brian Fox for the gnu project as a free software
replacement for the bourne shel
First released in 1989 it has been distributed widely as
the default login shell for Linux distributions and apple's
macoS ( formerly OS X)
Latest version of bash is 4,4
Bash Overview(cont
Bash is a command processor that typically runs in a text
window, where the user types commands that cause
actions. Bash can also read commands from a file, called
a script
Like all Unix shells, it supports filename globbing
(wildcard matching), piping, here documents, command
substitution variables and control structures for
condition-testing and iteration the keywords syntax and
other basic features of the language are all copied from
sh. Other features, e.g., history are copied from csh and
ksh
Bash is a posix shell. but with a number of extensions
Bash Programming
Special Parameters
Parameter Meaning
S? Exit status
ss PId of the shell
s! Pid of the job most recently placed into
the background
$# The number of positional parameters
so The name of the shell or shell script
s The absolute pathname of the shell
Bash Programming(2
Special Parameters
Examp
bash-4.3
bash-4.3$
800 AMD64
bash-4.3$ cat-n/tmp/foo. sh
File Edit View Search Terminal Help
1 #!/bin/bash
bash-4.3$ bash /tmp/foo. sh
2echo\$≡$
=/usr/bin/bash
3echo\$0=$0
$0=/tmp/foo. sh
4et:123456789as#=10
5echo\$#=$#
1=1$9=9$10=a
6eho\$1=199=9510=$105=9651
7echo\$\$=$$
$!=9652
8 sleep 5
bash-4.3$ echo $
9echo\$!=$!
99
10 exit 99
bash-4.3s
bash-4.3$
Bash Programming( 3)
Parameters Parsing
S# and so,51,…,Sn
S#: The number of positional parameters
so, $1, Sn: Positional parameters
fn>=10,useS{n}e.g.S{10}S{11}
S*vs S
Unquoted s* is the same as s
“S*"V.S.“S
S*" is equivalent to“S1S2…Sn
S" is equivalent to“S1"“s2”…."Ssn
Bash Programming(4
Parameters Parsing(2)
shift [n
The positional parameters from Sn+1.are renamed $1
Default n is 1
Often used in functions, or shift s(( oPtind-1 ))after getopts is
used
getopts
Don't have to manually parse parameters, use getopts instead
OPTARG is the value of the last option argument
OPTIND is the index of the last option argument
It also supports long options
Bash Programming(5
Variable Assignments
An assignment token is one of
varname=word
varname+=word
varnamelsubscript]=word
varnamelsubscript]+=word
No space is permitted between varname and the
=+=or between =/+= and word
The [] acts to quote special characters subscript can
be string or arithmetic
Bash Programming(6)
Variable Assignments(2)
The + form is for appending to a variable varname
If var type is string, new value is appended to the existing
string
If var type is arithmetic, new value is added to the existing
arithmetic value
If var type is indexed array new value is appended to the
existing indexed array
If var type is associative array, new value is appended to
the existing associative array
10
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.