📄 bash.0
字号:
files are read, shell functions are not inherited from the environment, the SSHHEELLLLOOPPTTSS, BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they appear in the environment, are ignored, and the effective user id is set to the real user id. If the --pp option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset.DDEEFFIINNIITTIIOONNSS The following definitions are used throughout the rest of this docu- ment. bbllaannkk A space or tab. wwoorrdd A sequence of characters considered as a single unit by the shell. Also known as a ttookkeenn. nnaammee A _w_o_r_d consisting only of alphanumeric characters and under- scores, and beginning with an alphabetic character or an under- score. Also referred to as an iiddeennttiiffiieerr. mmeettaacchhaarraacctteerr A character that, when unquoted, separates words. One of the following: || && ;; (( )) << >> ssppaaccee ttaabb ccoonnttrrooll ooppeerraattoorr A _t_o_k_e_n that performs a control function. It is one of the fol- lowing symbols: |||| && &&&& ;; ;;;; (( )) || ||&& <<nneewwlliinnee>>RREESSEERRVVEEDD WWOORRDDSS _R_e_s_e_r_v_e_d _w_o_r_d_s 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 SSHHEELLLL GGRRAAMMMMAARR below) or the third word of a ccaassee or ffoorr command: !! ccaassee ddoo ddoonnee eelliiff eellssee eessaacc ffii ffoorr ffuunnccttiioonn iiff iinn sseelleecctt tthheenn uunnttiill wwhhiillee {{ }} ttiimmee [[[[ ]]]]SSHHEELLLL GGRRAAMMMMAARR SSiimmppllee CCoommmmaannddss A _s_i_m_p_l_e _c_o_m_m_a_n_d is a sequence of optional variable assignments fol- lowed by bbllaannkk-separated words and redirections, and terminated by a _c_o_n_t_r_o_l _o_p_e_r_a_t_o_r. 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 _s_i_m_p_l_e _c_o_m_m_a_n_d is its exit status, or 128+_n if the command is terminated by signal _n. PPiippeelliinneess A _p_i_p_e_l_i_n_e is a sequence of one or more commands separated by one of the control operators || or ||&&. The format for a pipeline is: [ttiimmee [--pp]] [ ! ] _c_o_m_m_a_n_d [ [|||||&&] _c_o_m_m_a_n_d_2 ... ] The standard output of _c_o_m_m_a_n_d is connected via a pipe to the standard input of _c_o_m_m_a_n_d_2. This connection is performed before any redirec- tions specified by the command (see RREEDDIIRREECCTTIIOONN below). If ||&& is used, the standard error of _c_o_m_m_a_n_d is connected to _c_o_m_m_a_n_d_2's standard input through the pipe; it is shorthand for 22>>&&11 ||. This implicit redirect- ion 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 ppiippeeffaaiill option is enabled. If ppiippeeffaaiill 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 success- fully. 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 ttiimmee 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 --pp option changes the output format to that specified by POSIX. When the shell is in _p_o_s_i_x _m_o_d_e, it does not rec- ognize ttiimmee as a reserved word if the next token begins with a `-'. The TTIIMMEEFFOORRMMAATT variable may be set to a format string that specifies how the timing information should be displayed; see the description of TTIIMMEEFFOORRMMAATT under SShheellll VVaarriiaabblleess below. When the shell is in _p_o_s_i_x _m_o_d_e, ttiimmee 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 TTIIMMEEFFOORRMMAATT 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). LLiissttss A _l_i_s_t is a sequence of one or more pipelines separated by one of the operators ;;, &&, &&&&, or ||||, and optionally terminated by one of ;;, &&, or <<nneewwlliinnee>>. Of these list operators, &&&& and |||| have equal precedence, followed by ;; and &&, which have equal precedence. A sequence of one or more newlines may appear in a _l_i_s_t instead of a semicolon to delimit commands. If a command is terminated by the control operator &&, the shell exe- cutes the command in the _b_a_c_k_g_r_o_u_n_d in a subshell. The shell does not wait for the command to finish, and the return status is 0. Commands separated 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 _c_o_m_m_a_n_d_1 &&&& _c_o_m_m_a_n_d_2 _c_o_m_m_a_n_d_2 is executed if, and only if, _c_o_m_m_a_n_d_1 returns an exit status of zero. An OR list has the form _c_o_m_m_a_n_d_1 |||| _c_o_m_m_a_n_d_2 _c_o_m_m_a_n_d_2 is executed if and only if _c_o_m_m_a_n_d_1 returns 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. CCoommppoouunndd CCoommmmaannddss A _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d is one of the following: (_l_i_s_t) _l_i_s_t is executed in a subshell environment (see CCOOMMMMAANNDD EEXXEECCUU-- TTIIOONN EENNVVIIRROONNMMEENNTT below). Variable assignments and builtin com- mands that affect the shell's environment do not remain in effect after the command completes. The return status is the exit status of _l_i_s_t. { _l_i_s_t; } _l_i_s_t is simply executed in the current shell environment. _l_i_s_t must be terminated with a newline or semicolon. This is known as a _g_r_o_u_p _c_o_m_m_a_n_d. The return status is the exit status of _l_i_s_t. Note that unlike the metacharacters (( and )), {{ and }} are _r_e_s_e_r_v_e_d _w_o_r_d_s and must occur where a reserved word is permitted to be recognized. Since they do not cause a word break, they must be separated from _l_i_s_t by whitespace or another shell metacharacter. ((_e_x_p_r_e_s_s_i_o_n)) The _e_x_p_r_e_s_s_i_o_n is evaluated according to the rules described below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If the value of the expres- sion is non-zero, the return status is 0; otherwise the return status is 1. This is exactly equivalent to lleett ""_e_x_p_r_e_s_s_i_o_n"". [[[[ _e_x_p_r_e_s_s_i_o_n ]]]] Return a status of 0 or 1 depending on the evaluation of the conditional expression _e_x_p_r_e_s_s_i_o_n. Expressions are composed of the primaries described below under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS. Word splitting and pathname expansion are not performed on the words between the [[[[ and ]]]]; tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution, and quote removal are performed. Condi- tional operators such as --ff 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 pattern and matched according to the rules described below under PPaatttteerrnn MMaattcchhiinngg. If the shell option nnooccaasseemmaattcchh 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 pat- tern, and 1 otherwise. 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 expres- sion and matched accordingly (as in _r_e_g_e_x(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 nnooccaasseemmaattcchh 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 BBAASSHH__RREEMMAATTCCHH. The element of BBAASSHH__RREEMMAATTCCHH with index 0 is the portion of the string matching the entire regular expression. The element of BBAASSHH__RREEMMAATTCCHH with index _n is the portion of the string matching the _nth parenthe- sized subexpression. Expressions may be combined using the following operators, listed in decreasing order of precedence: (( _e_x_p_r_e_s_s_i_o_n )) Returns the value of _e_x_p_r_e_s_s_i_o_n. This may be used to override the normal precedence of operators. !! _e_x_p_r_e_s_s_i_o_n True if _e_x_p_r_e_s_s_i_o_n is false. _e_x_p_r_e_s_s_i_o_n_1 &&&& _e_x_p_r_e_s_s_i_o_n_2 True if both _e_x_p_r_e_s_s_i_o_n_1 and _e_x_p_r_e_s_s_i_o_n_2 are true.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -