bash
- 格式:pdf
- 大小:289.32 KB
- 文档页数:72
bash教程Bash 是一种运行在Unix/Linux系统上的脚本语言,常用于自动化任务、编写脚本程序等。
它是一个功能强大且灵活的命令行工具,可以通过编写简单的脚本来替代繁琐的手动操作,提高工作效率。
本文将介绍Bash的基本语法和常用命令,帮助初学者快速入门。
首先,我们需要了解一些基本概念。
Bash是“Bourne Again SHell”的缩写,它源于Unix的一种Shell语言。
Shell是一个解释性的编程语言,它直接与操作系统的内核进行交互。
Bash是Shell中最常用的一种,它提供了很多常用的命令和脚本操作。
在Bash中,我们可以使用#字符来添加注释,这些注释将被忽略。
接下来,我们将学习一些基本的Bash语法。
首先是变量。
在Bash中,我们可以通过在变量名前加$符号来引用变量。
例如,可以使用以下命令将值“Hello World”分配给变量message:message="Hello World"echo $message上述命令将打印出“Hello World”。
在Bash中,我们还可以进行算术运算。
使用$(( ))将表达式括起来,可以计算其结果。
例如:a=5b=$((a + 3))echo $b上述命令将打印出“8”。
Bash中的条件语句使用if-then-else结构。
例如,我们可以使用以下命令来判断一个数是否大于10:num=12if [ $num -gt 10 ]; thenecho "The number is larger than 10"elseecho "The number is smaller than 10"fi上述命令将打印出“The number is larger than 10”。
除了if语句,Bash还提供了循环语句。
最常见的循环语句是for和while循环。
例如,以下命令将打印出数字1到5:for i in {1..5}; doecho $idonewhile循环也是一种常用的循环结构。
bash教程Bash是一个常用的命令行shell,适用于Linux和macOS操作系统。
它提供了一种与计算机交互的方法,可以执行命令、编辑文件和处理数据等操作。
下面是一些常用的Bash命令和技巧,供参考:1. 认识BashBash是Bourne Again SHell的缩写,是Unix的一个自由软件,是Linux和macOS默认的shell。
2. 查看当前所在路径使用`pwd`命令可以查看当前所在路径。
比如输入`pwd`后回车,你将看到当前所在路径的完整名称。
3. 列出文件和文件夹使用`ls`命令可以列出当前路径下的文件和文件夹。
比如输入`ls`后回车,你将看到当前路径下的所有文件和文件夹的名称。
4. 切换路径使用`cd`命令可以切换路径。
比如输入`cd /path/to/folder`后回车,你将切换到指定路径。
5. 创建文件夹使用`mkdir`命令可以创建文件夹。
比如输入`mkdir foldername`后回车,你将在当前路径下创建一个名为"foldername"的文件夹。
6. 创建文件使用`touch`命令可以创建文件。
比如输入`touch filename`后回车,你将在当前路径下创建一个名为"filename"的空文件。
7. 复制文件和文件夹使用`cp`命令可以复制文件和文件夹。
比如输入`cp file1file2`后回车,你将复制名为"file1"的文件并将其重命名为"file2"。
8. 移动文件和文件夹使用`mv`命令可以移动文件和文件夹。
比如输入`mv file1 /path/to/destination`后回车,你将把名为"file1"的文件移动到指定路径下。
9. 删除文件和文件夹使用`rm`命令可以删除文件和文件夹。
比如输入`rm file1`后回车,你将删除名为"file1"的文件。
bash 语法bash语法是一种通用的编程语言,它是很多Unix系统上的默认登录shell。
它可用于大量功能,如创建和编辑文本文件,运行应用程序和脚本文件,配置系统环境变量,管理和运行Linux服务器,管理用户权限等等。
bash语法的语法结构基本上被称为命令行式语法,它的结构是通过命令、参数和选项来组织的。
它以带有提示符(bash)的窗口或内部 shell 为基础,并允许用户在终端控制台输入和运行linux系统命令。
bash语法大致分为三类:管道、脚本和shell变量。
管道用于将不同的命令组合在一起,脚本用于开发自定义脚本任务,而shell变量则提供用户可以用来定义变量值的一种方式。
在编写bash脚本时,关键点在于熟悉bash的一些基本概念,包括函数、变量、条件和循环等语句。
其中,函数是bash特有的特性,允许把它们组装成复杂的任务。
变量在bash编程中是必不可少的,它允许用户保存和访问各种类型的数据;条件语句允许根据某些情况运行或继续运行程序;循环语句让用户能够按照特定的规则重复执行程序的一部分。
最后,bash有很多内置命令,这些内置命令让开发者在一定程度上能够简化任务。
有了这些命令,用户就不必自己编写程序,就可以实现所需的某些功能,而不需要考虑底层实现细节。
另外,bash也提供了一些基于命令行的编辑器,使开发者能够以更加高效的方式编辑文件,并可以实现撤销与重做等类似功能。
总而言之,bash语法是一种非常有用的编程语言,它允许用户以高效、简单的方式实现对Unix系统功能和接口的管理和控制。
它让开发者可以比编写代码更快地实现功能,这使得它受到了很多技术人员的欢迎和应用。
Bash是什么以及Bash是什么意思?⽬前⽹上曝光了⼀个⾮常严重的Bash漏洞,它允许⿊客向服务器发出遥控指令,轻松盗取隐私信息,然⽽很多朋友对于Bash 是什么以及Bash是什么意思不了解,因此以下这篇知识扫盲⽂章,会给⼤家带来⼀定的帮助。
Bash是什么?bash是⼀个为GNU计划编写的Unix shell。
它的名字是⼀系列缩写:Bourne-Again SHell — 这是关于Bourne shell(sh)的⼀个双关语(Bourne again / born again)。
Bourne shell是⼀个早期的重要shell,由史蒂夫·伯恩在1978年前后编写,并同Version 7 Unix⼀起发布。
bash则在1987年由布莱恩·福克斯创造。
在1990年,Chet Ramey成为了主要的维护者。
bash是⼤多数Linux系统以及Mac OS X v10.4默认的shell,它能运⾏于⼤多数Unix风格的操作系统之上,甚⾄被移植到了Microsoft Windows上的Cygwin系统中,以实现windows的POSIX虚拟接⼝。
此外,它也被DJGPP项⽬移植到了MS-DOS 上。
2014年9⽉,多名⽹络安全专家发现⼀种在⽹络中已经隐藏20年的bug,这种名为Bash的漏洞⽐“⼼脏出⾎”漏洞的威胁还要严重。
⿊客可以通过它遥控向⽹络服务器发出指令,这意味着服务器受影响的公司将遇到⼤⿇烦。
因此,在当前,Bash是⼀个安全漏洞,允许⿊客向⽹络服务器发出遥控指令。
由于这种bug允许⿊客指令服务器去做任何他想做的事情,为此隐私信息很容易被从受影响的服务器中窃⾛。
Bash解决办法:1、下载最新的补丁进⾏修复,⽅法为:2、在机器上运⾏命令:$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test"如果返回以下内容:则请尽快升级。
bash 用法Bash(Bourne Again SHell)是一种流行的Unix shell,它是许多Linux和macOS系统的默认shell。
Bash提供了丰富的功能,包括命令行编辑、命令历史、别名、函数、作业控制等。
以下是Bash的一些基本用法:命令行编辑:Bash允许用户使用箭头键在命令行上移动,以便更正或修改命令。
还可以使用Tab键进行命令和文件名的自动补全。
命令历史:Bash会记住用户输入的命令,并允许用户通过按上/下箭头键来浏览这些命令。
用户还可以使用history命令查看命令历史记录。
别名:Bash允许用户为命令创建别名,以便用更短或更具描述性的名称来调用它们。
例如,alias ll='ls -l'会创建一个名为ll的别名,该别名将调用ls -l命令。
变量:Bash允许用户定义和使用变量。
例如,name="John"将创建一个名为name的变量,并将其设置为"John"。
用户可以通过在变量名前加上$符号来引用变量的值,如echo $name。
输入/输出重定向:Bash允许用户将命令的输出保存到文件中,或者将文件的内容作为命令的输入。
例如,command > file将命令的输出保存到file文件中,而command < file 则将file文件的内容作为命令的输入。
条件语句和循环:Bash提供了if、while、for等语句,允许用户根据条件执行不同的命令或重复执行同一组命令。
函数:Bash允许用户定义自己的函数,并在需要时调用它们。
函数是一组命令的集合,可以像单个命令一样被调用。
这只是Bash的一些基本用法。
Bash还提供了许多高级功能和选项,可以满足各种复杂的命令行需求。
要了解更多关于Bash的信息,建议参考Bash的官方文档或相关的学习资源。
bash命令用法
Bash(BourneAgainShell)是一款由BrianFox于1989年设计的传统的UnixShell,它是Gnu项目的一部分,是当今Linux和Unix操作系统的主要命令解释器。
Bash是Linux系统的缺省Shell。
虽然每种Shell具有一些共同的基本命令,但仍有很大差异,Bash以其独特的语法和更强大的功能而得到广泛使用。
本文主要介绍Bash命令的用法。
首先,Bash命令最基本的用法是执行系统命令。
Bash可以执行标准Linux命令,特殊字符及控制符或通配符等。
常见的系统命令有ls、cd、mkdir等。
其次,Bash可以用来执行shell脚本。
Shell脚本是一种文本文件,它利用Bash的语法编写,用于执行一系列的程序命令,可以实现更加灵活的操作。
此外,Bash还可以用于字符串操作。
Bash可以使用内置函数进行字符串操作,比如替换字符串,提取子字符串,查找字符串等等。
另外,Bash使用“if”这类条件判断来实现程序流程控制。
Bash的if语句有多种形式,可以用来实现复杂的逻辑控制,让程序执行更为智能化。
最后,Bash还可以用来配置环境变量。
Bash可以将变量的值设置为显式的值,也可以将变量的值设置为另一个变量的值,以便更加灵活地控制系统环境。
以上就是有关Bash命令用法的简介,Bash是目前Linux系统中最流行的Shell,它可以实现很多有用的功能,所以大家使用Linux系统的朋友们一定要掌握它,以免错过它带来的便利。
bash 教程Bash是一个常用的Shell脚本语言,被广泛用于Linux和Unix 系统中。
它是Bourne Shell的改进版,具有更多的功能和更强大的功能。
Bash的优势之一是其简洁性和易用性。
Bash脚本由一系列命令构成,通过这些命令和操作符可以完成各种任务。
它可以用于编写脚本程序,实现自动化任务和批量处理。
Bash脚本以文本文件形式保存,并以`.sh`为文件扩展名。
可以使用文本编辑器创建和编辑Bash脚本。
在Linux系统中,可以使用`vi`或`nano`等编辑器来进行编辑。
Bash脚本中的命令可以是系统命令、自定义命令或其他脚本文件。
脚本文件以`#!/bin/bash`作为开头,这是告诉系统使用Bash解释器来运行脚本的命令。
Bash脚本具有以下特性:1. 变量:可以使用变量来存储和操作数据。
Bash脚本中的变量以`$`符号开头,没有数据类型的限制。
可以通过赋值来创建变量,并在脚本中使用它们。
2. 条件语句:可以使用if语句来进行条件判断和分支控制。
根据条件的结果,可以执行不同的命令或操作。
3. 循环:可以使用不同类型的循环,如for循环、while循环和until循环。
循环可用于重复执行相同的命令或操作。
4. 输入输出重定向:可以使用输入输出重定向来控制命令的输入和输出。
例如,可以将命令的输出保存到文件中,或从文件中读取输入。
5. 函数:可以定义和使用函数来封装和重用一部分代码。
函数可以传递参数,并返回结果。
Bash脚本还支持各种其他功能,如字符串操作、数组、文件和目录处理、正则表达式等。
可以使用这些功能来完成复杂的任务。
总而言之,Bash是一种强大而灵活的Shell脚本语言,通过编写Bash脚本,可以实现各种自动化任务和系统管理操作。
使用Bash脚本,可以提高工作效率,并减少重复性的工作。
它是Linux和Unix系统中不可或缺的一部分。
bash常用命令
Bash(Bourne-again shell) 是 Unix 系统中的一种命令行Shell,它提供了大量的命令行工具,用于管理文件系统。
以下是一些常用的 Bash 命令:
1. cd(改变当前工作目录):表示改变当前工作目录。
2. ls(列出当前目录的文件和子目录):表示列出当前目录的文件和子目录。
3. pwd(显示当前工作目录的路径):表示显示当前工作目录的路径。
4. mkdir(创建目录):表示创建一个新的目录。
5. rm(删除文件或目录):表示删除指定的文件或目录。
6. cp(复制文件或目录):表示复制指定的文件或目录。
7. mv(移动文件或目录):表示移动指定的文件或目录。
8. cat(显示文件内容):表示显示指定的文件内容。
9. more(分屏显示文件):表示将文件内容分屏显示。
10. less(分屏显示文件):表示将文件内容分屏显示。
11. tail(显示文件的最后几行):表示显示文件的最后几行。
12. head(显示文件的前几行):表示显示文件的前几行。
13. sed(文本编辑命令):表示对文本进行编辑。
14. awk(文本处理命令):表示对文本进行处理。
15. find(查找目录):表示查找指定的目录。
16. grep(查找指定文本):表示在文件中查找指定文本。
除此之外,还有许多其他的命令,例如 chmod(修改文件或目录权限)、ssh(远程登录)、tar(打包和解压文件) 等,可以用于管理文件系统。
掌握这些命令可以提高工作效率,更好地理解 Unix 系统的运作方式。
bash命令参数
Bash是一个流行的基于文本的shell解释器,主要用于在Linux 和Unix操作系统上执行命令。
Bash支持许多参数来帮助用户更好地控制和管理命令的行为。
本文将介绍一些常用的Bash命令参数。
1. -a:将命令的输出附加到文件的末尾而不覆盖原有内容。
2. -c:从字符串中读取命令并执行。
3. -e:如果命令的退出状态为非零,则立即退出脚本。
4. -f:禁止使用文件名扩展功能。
5. -h:显示命令的帮助信息。
6. -i:交互式执行命令。
7. -n:检查脚本中的语法错误而不执行脚本。
8. -q:安静模式,禁止显示命令的输出。
9. -r:使变量成为只读变量。
10. -s:从标准输入读取命令并执行。
以上是一些常用的Bash命令参数,它们可以帮助用户更好地控制和管理命令的行为。
熟练掌握这些参数可以让你更加高效地使用Bash。
- 1 -。
NAMEbash − GNU Bourne-Again SHellSYNOPSISbash[options] [file]COPYRIGHTBash is Copyright © 1989-2011 by the Free Software Foundation, Inc.DESCRIPTIONBash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file.Bash also incorporates useful features from the Korn and C shells (ksh and csh).Bash is intended to be a conformant implementation of the Shell and Utilities portion of the IEEE POSIX specification (IEEE Standard 1003.1).Bash can be configured to be POSIX-conformant by default. OPTIONSAll of the single-character shell options documented in the description of the set builtin command can be used as options when the shell is invoked. In addition,bash interprets the following options when it is invoked:−c string If the−c option is present, then commands are read from string.If there are arguments after the string,they are assigned to the positional parameters, starting with$0.−i If the−i option is present, the shell is interactive.−l Make bash act as if it had been invoked as a login shell (see INVOCATION below).−r If the−r option is present, the shell becomes restricted(see RESTRICTED SHELL below).−s If the−s option is present, or if no arguments remain after option processing, then commands are read from the standard input.This option allows the positional parameters to be set wheninvoking an interactive shell.−D A list of all double-quoted strings preceded by$is printed on the standard output.These are the strings that are subject to language translation when the current locale is not C or POSIX.This implies the−n option; no commands will be executed.[−+]O [shopt_option]shopt_option is one of the shell options accepted by the shopt builtin (see SHELL BUILTINCOMMANDS below). If shopt_option is present,−O sets the value of that option;+O unsetsit. If shopt_option is not supplied, the names and values of the shell options accepted by shoptare printed on the standard output.If the invocation option is+O,the output is displayed in aformat that may be reused as input.−−A−−signals the end of options and disables further option processing.Any arguments after the−−are treated as filenames and arguments. An argument of−is equivalent to−−.Bash also interprets a number of multi-character options.These options must appear on the command line before the single-character options to be recognized.−−debuggerArrange for the debugger profile to be executed before the shell starts.Turns on extended debug-ging mode (see the description of the extdebug option to the shopt builtin below).−−dump−po−stringsEquivalent to−D,but the output is in the GNU gettext po(portable object) file format.−−dump−stringsEquivalent to−D.−−help Display a usage message on standard output and exit successfully.−−init−filefile−−rcfilefileExecute commands fromfile instead of the standard personal initialization file˜/.bashrc if theshell is interactive (see INVOCATION below).−−loginEquivalent to−l.−−noeditingDo not use the GNU readline library to read command lines when the shell is interactive.−−noprofileDo not read either the system-wide startup file/etc/profile or any of the personal initialization files˜/.bash_profile,˜/.bash_login,or˜/.profile.By default,bash reads these files when it is invoked asa login shell (see INVOCATION below).−−norc Do not read and execute the personal initialization file˜/.bashrc if the shell is interactive.This option is on by default if the shell is invoked as sh.−−posixChange the behavior of bash where the default operation differs from the POSIX standard tomatch the standard (posix mode).−−restrictedThe shell becomes restricted (see RESTRICTED SHELL below).−−verboseEquivalent to−v.−−versionShow version information for this instance of bash on the standard output and exit successfully. ARGUMENTSIf arguments remain after option processing, and neither the−c nor the−s option has been supplied, the first argument is assumed to be the name of a file containing shell commands.If bash is invoked in this fashion, $0is set to the name of the file, and the positional parameters are set to the remaining arguments.Bash reads and executes commands from this file, then exits.Bash’s exit status is the exit status of the last com-mand executed in the script.If no commands are executed, the exit status is 0.An attempt is first made to open the file in the current directory,and, if no file is found, then the shell searches the directories in PATH for the script.INVOCATIONA login shell is one whose first character of argument zero is a−,or one started with the−−login option.An interactive shell is one started without non-option arguments and without the−c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the−i option.PS1is set and$−includes i if bash is interactive,allowing a shell script or a startup file to test this state.The following paragraphs describe how bash executes its startup files.If any of the files exist but cannot be read,bash reports an error.Tildes are expanded in file names as described below under Tilde Expansion in the EXPANSION section.When bash is invoked as an interactive login shell, or as a non-interactive shell with the−−login option, it first reads and executes commands from the file/etc/profile,if that file exists. After reading that file, it looks for˜/.bash_profile,˜/.bash_login,and˜/.profile,in that order,and reads and executes commands from the first one that exists and is readable.The−−noprofile option may be used when the shell is started to inhibit this behavior.When a login shell exits,bash reads and executes commands from the file˜/.bash_logout,if it exists.When an interactive shell that is not a login shell is started,bash reads and executes commands from ˜/.bashrc,if that file exists. This may be inhibited by using the−−norc option. The−−rcfilefile option will force bash to read and execute commands fromfile instead of˜/.bashrc.When bash is started non-interactively,to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute.Bash behaves as if the following command were executed:if [ −n "$BASH_ENV" ]; then . "$BASH_ENV"; fibut the value of the PATH variable is not used to search for the file name.If bash is invoked with the name sh,it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well.When invoked as an interactive login shell, or a non-interactive shell with the−−login option, it first attempts to read and execute commands from/etc/profile and˜/.profile,in that order.The−−noprofile option may be used to inhibit this behavior.When invoked as an interactive shell with the name sh,bash looks for the variable ENV,expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the−−rcfile option has no effect. A non-interactive shell invoked with the name sh does not attempt to read any other startup files.When invoked as sh,bash enters posix mode after the startup files are read.When bash is started in posix mode, as with the−−posix command line option, it follows the POSIX stan-dard for startup files.In this mode, interactive shells expand the ENV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read.Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually rshd,or the secure shell daemon sshd.If bash deter-mines it is being run in this fashion, it reads and executes commands from˜/.bashrc,if that file exists and is readable. It will not do this if invoked as sh.The−−norc option may be used to inhibit this behavior,and the−−rcfile option may be used to force another file to be read, but rshd does not generally invoke the shell with those options or allow them to be specified.If the shell is started with the effective user (group) id not equal to the real user (group) id, and the−p option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS,BASHOPTS,CDPATH,and GLOBIGNORE variables, if they appear in the environment, are ignored, and the effective user id is set to the real user id.If the−p option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset.DEFINITIONSThe following definitions are used throughout the rest of this document.blank A space or tab.word A sequence of characters considered as a single unit by the shell.Also known as a token.name A word consisting only of alphanumeric characters and underscores, and beginning with an alpha-betic character or an underscore.Also referred to as an identifier.metacharacterA character that, when unquoted, separates words. One of the following:|&;()<>space tabcontrol operatorA token that performs a control function.It is one of the following symbols:|| & && ; ;; ( ) | |&<newline>RESERVED WORDSReserved words are words that have a special meaning to the shell.The following words are recognized as reserved when unquoted and either the first word of a simple command (see SHELL GRAMMAR below) or the third word of a case or for command:!case do done elif else esac fi for function if in select then untilwhile { } time [[ ]]SHELL GRAMMARSimple CommandsA simple command is a sequence of optional variable assignments followed by blank-separated words andredirections, and terminated by a control operator.The first word specifies the command to be executed, and is passed as argument zero.The remaining words are passed as arguments to the invoked command.The return value of a simple command is its exit status, or 128+n if the command is terminated by signal n.PipelinesA pipeline is a sequence of one or more commands separated by one of the control operators|or|&.Theformat for a pipeline is:[time[−p]] [ ! ]command[[| |&]command2... ]The standard output of command is connected via a pipe to the standard input of command2.This connec-tion is performed before any redirections specified by the command (see REDIRECTION below). If|&is used, the standard error of command is connected to command2’s standard input through the pipe; it is shorthand for2>&1 |.This implicit redirection of the standard error is performed after any redirections specified by the command.The return status of a pipeline is the exit status of the last command, unless the pipefail option is enabled.If pipefail is enabled, the pipeline’s return status is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully.If the reserved word!precedes a pipeline, the exit status of that pipeline is the logical negation of the exit status as described above.The shell waits for all commands in the pipeline to terminate before returning a value.If the time reserved word precedes a pipeline, the elapsed as well as user and system time consumed by its execution are reported when the pipeline terminates.The−p option changes the output format to that spec-ified by POSIX.When the shell is in posix mode,it does not recognize time as a reserved word if the next token begins with a ‘-’.The TIMEFORMAT variable may be set to a format string that specifies how the timing information should be displayed; see the description of TIMEFORMAT under Shell Variables below.When the shell is in posix mode,time may be followed by a newline. In this case, the shell displays the total user and system time consumed by the shell and its children.The TIMEFORMAT variable may be used to specify the format of the time information.Each command in a pipeline is executed as a separate process (i.e., in a subshell).ListsA list is a sequence of one or more pipelines separated by one of the operators;,&,&&,or||,and option-ally terminated by one of;,&,or<newline>.Of these list operators,&&and||have equal precedence, followed by;and&,which have equal prece-dence.A sequence of one or more newlines may appear in a list instead of a semicolon to delimit commands.If a command is terminated by the control operator&,the shell executes the command in the background ina subshell. The shell does not wait for the command to finish, and the return status is mands sepa-rated by a;are executed sequentially; the shell waits for each command to terminate in turn.The return status is the exit status of the last command executed.AND and OR lists are sequences of one of more pipelines separated by the&&and||control operators, respectively.AND and OR lists are executed with left associativity.An AND list has the form command1&&command2command2is executed if, and only if,command1returns an exit status of zero.An OR list has the formcommand1||command2command2is executed if and only if command1returns a non-zero exit status.The return status of AND and OR lists is the exit status of the last command executed in the list.Compound CommandsA compound command is one of the following:(list)list is executed in a subshell environment (see COMMAND EXECUTION ENVIRONMENT below).Variable assignments and builtin commands that affect the shell’s environment do not remain ineffect after the command completes.The return status is the exit status of list.{list;}list is simply executed in the current shell environment.list must be terminated with a newline or semicolon. This is known as a group command.The return status is the exit status of list.Notethat unlike the metacharacters(and),{and}are reserved words and must occur where a reservedword is permitted to be recognized.Since they do not cause a word break, they must be separated from list by whitespace or another shell metacharacter.((expression))The expression is evaluated according to the rules described below under ARITHMETIC EV ALUA-TION.If the value of the expression is non-zero, the return status is 0; otherwise the return status is 1.This is exactly equivalent to let "expression".[[expression]]Return a status of 0 or 1 depending on the evaluation of the conditional expression expression.Expressions are composed of the primaries described below under CONDITIONAL EXPRES-SIONS.Word splitting and pathname expansion are not performed on the words between the[[ and]];tilde expansion, parameter and variable expansion, arithmetic expansion, command substi-tution, process substitution, and quote removal are performed.Conditional operators such as−f must be unquoted to be recognized as primaries.When used with[[,the<and>operators sort lexicographically using the current locale.When the==and!=operators are used, the string to the right of the operator is considered a pat-tern and matched according to the rules described below under Pattern Matching.If the shell option nocasematch is enabled, the match is performed without regard to the case of alphabetic characters. The return value is 0 if the string matches (==)or does not match (!=)the pattern, and 1otherwise. Any part of the pattern may be quoted to force it to be matched as a string.An additional binary operator,=˜,is available, with the same precedence as==and!=.When it is used, the string to the right of the operator is considered an extended regular expression and matched accordingly (as in regex(3)). The return value is 0 if the string matches the pattern, and 1 otherwise. If the regular expression is syntactically incorrect, the conditional expression’s return value is 2.If the shell option nocasematch is enabled, the match is performed without regard to the case of alphabetic characters.Any part of the pattern may be quoted to force it to be matched as a string.Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BASH_REMATCH.The element of BASH_REMATCH with index0is the portion of the string matching the entire regular expression. The element of BASH_REMATCH with index n is the portion of the string matching the n th parenthesized subexpression.Expressions may be combined using the following operators, listed in decreasing order of prece-dence:(expression)Returns the value of expression.This may be used to override the normal precedence ofoperators.!expressionTrue if expression is false.expression1&&expression2True if both expression1and expression2are true.expression1||expression2True if either expression1or expression2is true.The&&and||operators do not evaluate expression2if the value of expression1is sufficient to determine the return value of the entire conditional expression.for name[[in[word...]];]do list;doneThe list of words following in is expanded, generating a list of items.The variable name is set to each element of this list in turn, and list is executed each time.If the in word is omitted, the for command executes list once for each positional parameter that is set (see PARAMETERS below).The return status is the exit status of the last command that executes. If the expansion of the items following in results in an empty list, no commands are executed, and the return status is 0.for((expr1;expr2;expr3)) ;do list;doneFirst, the arithmetic expression expr1is evaluated according to the rules described below underARITHMETIC EV ALUATION.The arithmetic expression expr2is then evaluated repeatedly untilit evaluates to zero.Each time expr2evaluates to a non-zero value,list is executed and the arith-metic expression expr3is evaluated. If any expression is omitted, it behaves as if it evaluates to 1.The return value is the exit status of the last command in list that is executed, or false if any of theexpressions is invalid.select name[in word];do list;doneThe list of words following in is expanded, generating a list of items.The set of expanded wordsis printed on the standard error,each preceded by a number.If the in word is omitted, the posi-tional parameters are printed (see PARAMETERS below). The PS3prompt is then displayed and aline read from the standard input.If the line consists of a number corresponding to one of the dis-played words, then the value of name is set to that word. If the line is empty,the words andprompt are displayed again. If EOF is read, the command completes.Any other value read causesname to be set to null.The line read is saved in the variable REPLY.The list is executed aftereach selection until a break command is executed. The exit status of select is the exit status of thelast command executed in list,or zero if no commands were executed.case word in[[(]pattern[|pattern]... )list;; ] ...esacA case command first expands word,and tries to match it against each pattern in turn, using thesame matching rules as for pathname expansion (see Pathname Expansion below). The word isexpanded using tilde expansion, parameter and variable expansion, arithmetic substitution, com-mand substitution, process substitution and quote removal. Each pattern examined is expandedusing tilde expansion, parameter and variable expansion, arithmetic substitution, command substi-tution, and process substitution.If the shell option nocasematch is enabled, the match is per-formed without regard to the case of alphabetic characters.When a match is found, the corre-sponding list is executed. If the;;operator is used, no subsequent matches are attempted after thefirst pattern ing;&in place of;;causes execution to continue with the list associatedwith the next set of ing;;&in place of;;causes the shell to test the next pattern list inthe statement, if any, and execute any associated list on a successful match.The exit status is zeroif no pattern matches.Otherwise, it is the exit status of the last command executed in list.if list;then list;[elif list;then list;]... [else list;]fiThe if list is executed. If its exit status is zero, the then list is executed. Otherwise,each elif listis executed in turn, and if its exit status is zero, the corresponding then list is executed and thecommand completes.Otherwise, the else list is executed, if present.The exit status is the exit sta-tus of the last command executed, or zero if no condition tested true.while list-1;do list-2;doneuntil list-1;do list-2;doneThe while command continuously executes the list list-2as long as the last command in the listlist-1returns an exit status of zero.The until command is identical to the while command, exceptthat the test is negated;list-2is executed as long as the last command in list-1returns a non-zeroexit status.The exit status of the while and until commands is the exit status of the last commandexecuted in list-2,or zero if none was executed.CoprocessesA coprocess is a shell command preceded by the coproc reserved word. A coprocess is executed asyn-chronously in a subshell, as if the command had been terminated with the&control operator,with a two-way pipe established between the executing shell and the coprocess.The format for a coprocess is:coproc[NAME]command[redirections]This creates a coprocess named NAME.If NAME is not supplied, the default name is must not be supplied if command is a simple command(see above); otherwise, it is interpreted as the first word of the simple command.When the coproc is executed, the shell creates an array variable (see Arraysbelow) named NAME in the context of the executing shell.The standard output of command is connected via a pipe to a file descriptor in the executing shell, and that file descriptor is assigned to NAME[0]. The standard input of command is connected via a pipe to a file descriptor in the executing shell, and that file descriptor is assigned to NAME[1]. This pipe is established before any redirections specified by the com-mand (see REDIRECTION below). Thefile descriptors can be utilized as arguments to shell commands and redirections using standard word expansions. The process ID of the shell spawned to execute the coprocess is available as the value of the variable NAME_PID. The wait builtin command may be used to wait for the coprocess to terminate.The return status of a coprocess is the exit status of command.Shell Function DefinitionsA shell function is an object that is called like a simple command and executes a compound command witha new set of positional parameters.Shell functions are declared as follows:name()compound−command[redirection]function name[()]compound−command[redirection]This defines a function named name.The reserved word function is optional.If the functionreserved word is supplied, the parentheses are optional.The body of the function is the compoundcommand compound−command(see Compound Commands above). That command is usually alist of commands between { and }, but may be any command listed under Compound Commandspound−command is executed whenever name is specified as the name of a simplecommand. Any redirections (see REDIRECTION below) specified when a function is defined areperformed when the function is executed. The exit status of a function definition is zero unless asyntax error occurs or a readonly function with the same name already exists. When executed, theexit status of a function is the exit status of the last command executed in the body.(See FUNC-TIONS below.)COMMENTSIn a non-interactive shell, or an interactive shell in which the interactive_comments option to the shopt builtin is enabled (see SHELL BUILTIN COMMANDS below), a word beginning with#causes that word and all remaining characters on that line to be ignored.An interactive shell without the interactive_com-ments option enabled does not allow comments. The interactive_comments option is on by default in interactive shells.QUOTINGQuoting is used to remove the special meaning of certain characters or words to the shell.Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion.Each of the metacharacters listed above under DEFINITIONS has special meaning to the shell and must be quoted if it is to represent itself.When the command history expansion facilities are being used (see HISTORY EXPANSION below), the history expansion character,usually!,must be quoted to prevent history expansion.There are three quoting mechanisms: the escape character,single quotes, and double quotes.A non-quoted backslash (\)is the escape character.It preserves the literal value of the next character thatfollows, with the exception of <newline>. If a\<newline> pair appears, and the backslash is not itself quoted, the\<newline> is treated as a line continuation (that is, it is removed from the input stream and effectively ignored).Enclosing characters in single quotes preserves the literal value of each character within the quotes.A sin-gle quote may not occur between single quotes, even when preceded by a backslash.Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of$,`,\,and, when history expansion is enabled,!.The characters$and`retain their special meaning within double quotes.The backslash retains its special meaning only when followed by one of the following characters:$,`,",\,or<newline>.A double quote may be quoted within double quotes by pre-ceding it with a backslash.If enabled, history expansion will be performed unless an!appearing in doublequotes is escaped using a backslash.The backslash preceding the!is not removed.The special parameters*and@have special meaning when in double quotes (see PARAMETERS below).Words of the form$'string'are treated specially.The word expands to string,with backslash-escaped char-acters replaced as specified by the ANSI C standard.Backslash escape sequences, if present, are decoded as follows:\a alert (bell)\b backspace\e\E an escape character\f form feed\n new line\r carriage return\t horizontal tab\v vertical tab\\backslash\'single quote\"double quote\nnn the eight-bit character whose value is the octal value nnn(one to three digits)\x HH the eight-bit character whose value is the hexadecimal value HH(one or two hex digits)\u HHHHthe Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHH(one to four hex digits)\U HHHHHHHHthe Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHHH-HHH(one to eight hex digits)\c x a control-x characterThe expanded result is single-quoted, as if the dollar sign had not been present.A double-quoted string preceded by a dollar sign ($"string") will cause the string to be translated accordingto the current locale.If the current locale is C or POSIX,the dollar sign is ignored.If the string is trans-lated and replaced, the replacement is double-quoted.PARAMETERSA parameter is an entity that stores values. It can be a name,a number,or one of the special characterslisted below under Special Parameters.A variable is a parameter denoted by a name.A variable has a value and zero or more attributes.Attributes are assigned using the declare builtin command (see declare below in SHELL BUILTIN COMMANDS).A parameter is set if it has been assigned a value. The null string is a valid value. Once a variable is set, itmay be unset only by using the unset builtin command (see SHELL BUILTIN COMMANDS below).A variable may be assigned to by a statement of the formname=[value]If value is not given, the variable is assigned the null string.All values undergo tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal(see EXPANSION below). If the variable has its integer attribute set, then value is evaluated as an arithmetic expression even if the $((...)) expansion is not used (see Arithmetic Expansion below). Word splitting is not performed, with the exception of"$@"as explained below under Special Parameters.Pathname expansion is not performed. Assignment statements may also appear as arguments to the alias,declare,typeset,export, readonly,and local builtin commands.In the context where an assignment statement is assigning a value to a shell variable or array index, the += operator can be used to append to or add to the variable’s previous value. When+= is applied to a variable for which the integer attribute has been set,value is evaluated as an arithmetic expression and added to the variable’s current value, which is also evaluated. When+= is applied to an array variable using compound。