BASH(1) General Commands Manual BASH(1) bash - GNU Bourne-Again bash [options] [command_string | file] Bash is Copyright (C) 1989-2025 by the Free Software Foundation, Inc. Bash - , , , . Bourne, Unix. Bash Korn C (ksh csh). POSIX - , Unix. Bash , IEEE POSIX ( IEEE 1003.1). Bash POSIX ( posix mode) , , . , , posix mode bash. Bash POSIX . , set, -o, . , bash : -c -c, , , command_string. command_string , $0, . $0 , . -i -i, . -l bash , ( ). -r -r, restricted,.. ( ). -s -s , . . -D , , $. , , C POSIX. -n; . [-+]O [shopt_option] shopt_option - , shopt ( ). shopt_option , -O ; +O . shopt_option , bash , shop, . +O, , . -- -- . -- (. ) . - --. Bash , . , , . --debugger , . ( extdebug shopt ). --dump-po-strings -D, GNU gettext "po" ( ). --dump-strings -D. --help . --init-file file --rcfile file file ~/.bashrc ( ). --login -l. --noediting GNU readline , . --noprofile /etc/profile ~/.bash_profile, ~/.bash_login, ~/.profile. bash , ( ). --norc ~/.bashrc . , sh. --posix posix; bash, POSIX , . --restricted ( ). --verbose -v. --version bash . , -c -s , , (shell script). bash , $0 , . Bash , . Bash - , . , 0. Bash , , , PATH. (login shell) - , - , --login. interactive shell - , ( -s) -c, ( isatty(3)) -i. , Bash PS1, $- i, . , bash . - , , bash . , . bash --login, /etc/profile, . ~/.bash_profile, ~/.bash_login, ~/.profile, . --noprofile. exit, bash ~/.bash_logout, . , , bash ~/.bashrc, . --norc . --rcfile file bash file ~/.bashrc. bash , , , BASH_ENV , , . Bash , : if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi PATH . bash sh, sh, POSIX --login /etc/profile ~/.profile, . --noprofile . sh, bash ENV, , . , sh, - , --rcfile . , sh, - . sh, bash posix . bash posix, --posix, POSIX . ENV, , . , , . Bash , , , , , rshd, sshd. bash , , ~/.bashrc, . Bash , sh. --norc , --rcfile bash ~/.bashrc, rshd, sshd . (), (), -p , , , SHELLOPTS, BASHOPTS, CDPATH GLOBIGNORE, , , . -p, , . . blank . whitespace , space isspace(3) true. word , . token. name word, - . identifier. metacharacter metacharacter - , , , . : | & ; ( ) < > space tab newline control operator token, . : || & && ; ;; ;& ;;& ( ) | |& Reserved words - , . , ( ), case select ( in), for ( in do): ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] . Simple Commands simple command - , ( blank) , control operator. , . . . simple command - 128+n, n. Pipelines () pipeline , | |&. : [time [-p]] [ ! ] command1 [ [|||&] command2 ... ] command1 command2. , command1( ). |& , command1, , command2 . 2>&1 |. , command1. - , pipefail. pipefail , ( ) , , . ! , , . , , . time , , , , . -p POSIX . posix, time , "-". TIMEFORMAT , , . TIMEFORMAT . posix, time . , . TIMEFORMAT . , , subshell, . . lastpipe shopt ( shopt ), , . list - , ;, &, && || ;, & . && || , ; &, . list . &, background . 0. asynchronous . , ;, ; . - . , && ||, . . command1 && command2 command2 , command1 (). command1 || command2 command2 , command1 . - , . Compound Commands compound command - . list , . (list) list ( ). , , . - list. { list; } list . list . group command. - list. , ( ), { } reserved words , . , list . ((expression)) expression , . , 0; 1. expression , , expression . , , 0. [[ expression ]] expression (true) (false) . , . [[ ]] . , , , , . , -f, , . [[ < > . == !=, , , extglob. = ==. nocasematch, . 0, (==) (!=) , 1 . - , : , - . =~, , == !=. POSIX ( POSIX regcomp regexec, regex(3)). 0, , 1 . , 2. nocasematch, . - , , , , . , , , . , . , - . ^ $, . BASH_REMATCH , . BASH_REMATCH 0 , . , , BASH_REMATCH. BASH_REMATCH n - , n- , . Bash BASH_REMATCH ; . , : ( expression ) expression. . ! expression expression . expression1 && expression2 , expression1 expression2 . expression1 || expression2 , expression1 expression2 . && || expression2, expression1 . for name [ [ in word ... ] ; ] do list ; done , in, . name , list . in word , for list ( ). - . , in, (list) , , 0. for (( expr1 ; expr2 ; expr3 )) [;] do list ; done expr1 , . expr2, . , expr2 , list expr3. - , , 1. - list , - . break continue ( ) . select name [ in word ] ; do list ; done , in, , , . in word , ( ). select PS3 . , , select name . , select . EOF , select 1. name l. REPLY. list , break. select - , list, , . case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac case word pattern , , , . - , , ) . word , , , , . pattern , , , , . nocasematch, . clause - list. , case list. ;; case, case . ;& ;; list, . ;;& ;; , , , list, , case, . , . , list. if list; then list; [ elif list; then list; ] ... [ else list; ] fi if list. , then list. elif list , , then list . else list, . - , . while list-1; do list-2; done until list-1; do list-2; done while list-2 , list-1 . until while, , : list-2 , list-1 . while until - , list-2, , . Coprocesses coprocess - , coproc. , &, . : coproc [NAME] command [redirections] NAME. command , ( ). NAME - . NAME , COPROC. - coproc NAME { command [redirections]; } , , COPROC, , . command , NAME . , coproc, , : NAME, , . command , NAME ; , NAME . , ( ) NAME . command , NAME[0]. command , NAME[1]. , ( ). . , , , . ID, , NAME_PID. wait . , coproc . - command. - , . : fname () compound-command [redirection] function fname [()] compound-command [redirection] fname. function . function, . body - compound-command ( ). list { }, , . function, , . compound-command , fname . posix name POSIX special builtins. , $. ( ), , . , , , . , ( ). , interactive_comments shopt ( ), , #, . , . , . interactive_comments . interactive_comments . Quoting . , . metacharacters, , , . ( ), , ( !) history expansion, . : escape escape character, , . (\) - escape character - . , , . \, , \ ( ). . , . , $, `, \ , , !. posix, ! , . $ ` . , : $, `, ", \ . , , . , . , , !, , . , !, . * @ , ( ). $'string' . string, , , string ANSI C. , , : \a () \b \e \E \f \n \r \t \v \\ \' \" \? \nnn , nnn ( ). \xHH , HH ( ). \uHHHH Unicode (ISO/IEC 10646), HHHH ( ). \UHHHHHHHH Unicode (ISO/IEC 10646), HHHHHHHH ( ). \cx -x. , . , , ($"string"), . gettext , LC_MESSAGES, TEXTDOMAINDIR TEXTDOMAIN. C POSIX, , , , . , , . noexpand_translation shopt, , . shopt . parameter - , . name, , . variable - , name. value attributes. declare ( declare ). export readonly . , . . , , unset ( ). variable name=[value] value , . value , , , ( ). integer, value , $((...)) ( ). . alias, declare, typeset, export, readonly local ( declaration). posix command . , , "+=" . declaration, declare, . "+=" , integer, value , . , . "+=" ( ), ( "="), , , ( ), - . , , value . nameref, -n declare local ( declare local ), nameref . . , nameref, , ( nameref), , nameref. nameref , . , , declare -n ref=$1 nameref, ref, . ref, , , $1. for nameref, , , , . nameref. nameref . nameref , -n unset. , unset nameref , , nameref, . , , , ( ). positional parameter - , , 0. set. . ( ). , , , ( ). , $, ($1-$9) $0 ( ). . ; . . * ($*) , . , . , , . , , IFS. , "$*" "$1c$2c...", c - IFS. IFS , . IFS , . @ ($@) , . , , ; , . , , , , , . , . , "$@" "$1" "$2" ... , . , "$@" $@ (.. ). # ($#) . ? ($?) . - ($-) , set (, -i). $ ($$) ID . , . ! ($!) , , , bg ( ). 0 ($0) . . bash , $0 . bash -c, $0 , , . , bash, . : _ ($_, ) . _ , , . , , , . , , , . $_ . BASH , bash. BASHOPTS , . -s shopt ( ). , BASHOPTS, - , shopt on. bash, . , . . BASHPID ID bash. $$ , , , bash. BASHPID . BASHPID , , . BASH_ALIASES , , alias. , , ; . BASH_ALIASES , , . BASH_ARGC , bash. ( , . source) . , BASH_ARGC. BASH_ARGC ( extdebug shopt ). extdebug , , , extdebug , . BASH_ARGC . BASH_ARGV , bash. ; . , BASH_ARGV. BASH_ARGV ( extdebug shopt ). extdebug , , , extdebug , . BASH_ARGV . BASH_ARGV0 ( $0; 0 ). BASH_ARGV0 $0 . BASH_ARGV0 , , . BASH_CMDS , - , hash. -; -. BASH_CMDS , , . BASH_COMMAND , - , , , . BASH_COMMAND , , . BASH_EXECUTION_STRING -c. BASH_LINENO , , FUNCNAME. ${BASH_LINENO[$i]} - (${BASH_SOURCE[$i+1]}), ${FUNCNAME[$i]} ( ${BASH_LINENO[$i-1]}, ). LINENO, . BASH_LINENO . BASH_LOADABLES_PATH , , enable . BASH_MONOSECONDS , , . , EPOCHSECONDS. BASH_MONOSECONDS , , . BASH_REMATCH , =~ [[. 0 - , . n - , n- , . BASH_SOURCE , , FUNCNAME. ${FUNCNAME[$i]} ${BASH_SOURCE[$i]} ${BASH_SOURCE[$i+1]}. BASH_SOURCE . BASH_SUBSHELL , . 0. BASH_SUBSHELL , , . BASH_TRAPSIG , . trap trap. BASH_VERSINFO , , bash. : BASH_VERSINFO[0] (the release). BASH_VERSINFO[1] (the version). BASH_VERSINFO[2] . BASH_VERSINFO[3] . BASH_VERSINFO[4] (, beta). BASH_VERSINFO[5] MACHTYPE. BASH_VERSION , bash (, 5.2.37(3)). COMP_CWORD ${COMP_WORDS}, . , ( ). COMP_KEY ( ), . , ( ). COMP_LINE . , ( ). COMP_POINT . , ${#COMP_LINE}. , ( ). COMP_TYPE , , : TAB, - ?, - !, - @, , , % . , ( ). COMP_WORDBREAKS , readline . COMP_WORDBREAKS , , . COMP_WORDS ( ), . , readline, COMP_WORDBREAKS, . , (. ). COPROC ( ), ( ). DIRSTACK ( ), . , dirs. , , pushd popd. . DIRSTACK , , . EPOCHREALTIME , Unix ( time(3)), . EPOCHREALTIME . EPOCHREALTIME , , . EPOCHSECONDS , , Unix ( time(3)). EPOCHSECONDS . EPOCHSECONDS , , . EUID , . . FUNCNAME , , . 0- . (, ) "main". . FUNCNAME . FUNCNAME , , . BASH_LINENO BASH_SOURCE. FUNCNAME BASH_LINENO BASH_SOURCE . , ${FUNCNAME[$i]} ${BASH_SOURCE[$i+1]} ${BASH_LINENO[$i]}. caller , . GROUPS , , . GROUPS . GROUPS , , . HISTCMD . HISTCMD . HISTCMD , , . HOSTNAME . HOSTTYPE , , bash. . LINENO , ( 1) . , , . LINENO , , . MACHTYPE , , bash, GNU cpu-company-system. . MAPFILE ( ), , mapfile, . OLDPWD , cd. OPTARG , getopts ( ). OPTIND , getopts ( ). OSTYPE , , bash. . PIPESTATUS ( ), , ( ). Bash PIPESTATUS , , , , , [[ ((, , . PPID . . PWD , cd. RANDOM 0 32767. RANDOM () . . RANDOM , , . READLINE_ARGUMENT , readline, "bind -x" ( ), . READLINE_LINE readline, "bind -x" ( ). READLINE_MARK ( ) readline "bind -x" ( ). region. READLINE_POINT readline "bind -x" ( ). REPLY , read, . SECONDS . SECONDS , , . . SECONDS , , . SHELLOPTS , . -o set ( ). , SHELLOPTS, on set -o. bash, . , . . SHLVL bash. SRANDOM 32- . , /dev/urandom arc4random(3), , . , . SRANDOM , , . UID , . . . bash ; . BASH_COMPAT . . (, 4,2) (, 42), . BASH_COMPAT , . BASH_COMPAT , , . , . , 4.2 42 , compat42 shopt 42. . BASH_ENV , bash , , . BASH_ENV , , . PATH . BASH_XTRACEFD , , bash , "set -x" , . , BASH_XTRACEFD . BASH_XTRACEFD . , BASH_XTRACEFD 2 ( ), . CDPATH cd. , , cd. ".:~:/usr". CHILD_MAX , . Bash POSIX - , ( 8192), . . COLUMNS select . , checkwinsize SIGWINCH. COMPREPLY , bash , , ( ). . EMACS bash , "t", , Emacs, . ENV BASH_ENV ( ) posix. EXECIGNORE , ( ), , PATH. , , PATH. [, test [[. - EXECIGNORE. , , , . extglob. FCEDIT fc. FIGNORE , ( READLINE ). , FIGNORE, . ".o:~". FUNCNEST , 0, . , , . GLOBIGNORE , , , . , , GLOBIGNORE, . extglob. GLOBSORT , . . , , LC_COLLATE. , +, , -, , . name, numeric, size, mtime, atime, ctime blocks, , , , .. , , , , . - , , (, ), . , -mtime ( ). numeric , , .. ( "2" "10", ). numeric , , , , . nosort ; bash , , -. , name, + , - . . HISTCONTROL , . ignorespace, , space, . ignoredups , , , . ignoreboth ignorespace ignoredups. erasedups , , , . , , . HISTCONTROL , bash , , , HISTIGNORE. , HISTCONTROL. , . HISTFILE , ( ). Bash , ~/.bash_history. HISTFILE , . HISTFILESIZE , . , , , , . , , , . history. 0, . , , . HISTSIZE . HISTIGNORE , , . HISTIGNORE, . (bash "*"). , HISTCONTROL. , , "&" . "&"; . , HISTIGNORE. , . extglob. HISTIGNORE HISTCONTROL. "&" "ignoredups", "[ ]*" "ignorespace". , , "ignoreboth". HISTSIZE , ( . 0, . , , , ( ). 500. HISTTIMEFORMAT , , strftime(3) , , history. , , . , . HOME ; cd. . HOSTFILE /etc/hosts , . ; bash . HOSTFILE , , , bash /etc/hosts . HOSTFILE , bash . IFS Internal Field Separator, read. . "". IGNOREEOF EOF . , EOF, bash. , , 10. , EOF . INPUTRC readline, ~/.inputrc ( READLINE ). INSIDE_EMACS , bash , Emacs , TERM. LANG , , , LC_. LC_ALL LANG LC_, . LC_COLLATE , , , . LC_CTYPE . LC_MESSAGES , , , $. LC_NUMERIC , . LC_TIME , . LINES select . , checkwinsize, SIGWINCH. MAIL , MAILPATH , bash Maildir. MAILCHECK , ( ) bash . 60 . , . , , , . MAILPATH , . , , , "?". , $_ . : MAILPATH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"' Bash , ( ), (, /var/mail/$USER). OPTERR 1, bash , getopts ( ). OPTERR 1 . PATH . , ( ). (null) PATH . . , bash. /usr/local/bin:/usr/local/sbin:.if 0<78n .br /usr/bin:/usr/sbin:/bin:/sbin POSIXLY_CORRECT bash, posix , --posix. , bash posix, "set -o posix" . posix, , . PROMPT_COMMAND , . , , . PROMPT_DIRTRIM , , , \w \W ( ). . PS0 ( ) . PS1 ( " ") . - "\s-\v\$ ". PS2 , PS1 . "> ". PS3 select ( ). PS4 , PS1 bash . PS4 , . "+ ". SHELL . , bash . TIMEFORMAT , , time. % , . ; . %% %. %[p][l]R . %[p][l]U , . %[p][l]S , . %P , (%U + %S) / %R. p - , precision, . . . 0 . time ; p, 6, 6. p , time . l , , MMmSS.FFs. p , . , bash , $'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'. , bash . . TMOUT , , read - . select , TMOUT , . , . Bash , . TMPDIR , bash , bash . auto_resume . , , , , . ; , , , . name - , , jobs. exact, ; substring, . substring , %? ( ). (, prefix), ; , %string. histchars , , ( ). - history expansion, "!". - quick substitution ( ), "^". , , . - history comment, "#", , , . . , . Bash . ; declare . , - , . , ( ) ; . , . , , . , , 0. , , , . . Bash , - name[subscript]=value . subscript , . () , declare -a name ( ). declare -a name[subscript] ; subscript . declare -A name . declare readonly. . name=(value1 ... valuen), value [subscript]=string. , string. value , , value, , , , . , , ; , . . , , , : name=( key1 value1 key2 value2 ...). name=( [key1]=value1 [key2]=value2 ...). , ; . / ; . declare. name[subscript]=value, . , name , , name, , , -1, . "+=" ; . ${name[subscript]}. , . subscript @ *, name, . , . , {name[*]} , IFS, ${name[@]} name . , ${name[@]} . , , . * @ ( ). ${#name[subscript]} ${name[subscript]}. subscript * @, . subscript, , , , , , , , -1, . , 0. ; bash . , . . () , . ${!name[@]} ${!name[*]} , name. @ * . unset . unset name[subscript] subscript , . , . . unset name, name . unset name[subscript] - , name , subscript * @. name , * @ . name , unset , . , , unset, , (, unset a[4]), . , (, unset 'a[4]'). declare, local readonly -a -A . , -A. read -a, , , . set declare , . "array name" (, mapfile); . . , . : brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, word splitting, pathname expansion quote removal. : ; , , ( ); ; ; . , , : process substitution. , , , . Quote removal . , , , - , . , ; . "$@" "${name[@]}", , , $* ${name[*]}, ( ). Brace expansion - , . pathname expansion, . , , preamble, , , , postscript. , , , , . . ; . , a{d,c,b}e "ade ace abe". x..y[..incr], x y , , incr, , . , x y, . x y , , . , x y, , C. , x, y ( ). . 1 -1, . , , . . Bash . , , . . A "{" Q , , . "${" , , "}". , , : mkdir /usr/local/src/bash/{old,new,dist,bugs} chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} sh. sh , , . Bash . , , sh "file{1,2}" . Bash "file1 file2" . bash +B +B set ( ) sh. ( "~"), , ( , ), tilde-prefix. , , , login name. , HOME. HOME , , . , . "~+", PWD, . "~-", OLDPWD, . , , N, a "+" "-", , dirs , , . , , "+" "-", "+". , , . , . Bash , : = . , PATH, MAILPATH CDPATH . Bash , ( ), . Bash , declaration , , posix. "$" , . , , , . "}" , , , . ${parameter} parameter. , parameter , , parameter , . parameter , () (). parameter (!), parameter nameref, . Bash , parameter, parameter; , , parameter. indirect expansion. , , . parameter nameref, , parameter, . ${!prefix*} ${!name[@]}, . , . word , , . , (, :-), bash , . , . ${parameter:-word} Use Default Values. parameter , word. parameter. ${parameter:=word} Assign Default Values. parameter , word parameter parameter. . ${parameter:?word} , Display Error if Null or Unset. parameter , word ( , word ) , , . , , . parameter. ${parameter:+word} Use Alternate Value. parameter , , word. parameter . ${parameter:offset} ${parameter:offset:length} Substring Expansion. length parameter, , offset. parameter @ *, , @ * , , . :length ( , ), offset, , parameter . offset , 0. length , offset , 0. length offset ( ). offset , , parameter. length , , parameter, , offset . . , :-. parameter @ *, length , offset. offset , , , -1, ( 0, ). , length , . parameter - , @ *, length , ${parameter[offset]}. offset , . length , . , , . , , 1 . offset 0 , $0. ${!prefix*} ${!prefix@} , Names matching prefix. , prefix, IFS. @ , . ${!name[@]} ${!name[*]} List of array keys. name , (), name. name , 0, name, . @ , . ${#parameter} Parameter length. parameter. parameter * @, . parameter - , * @, - - . parameter - , , , parameter, , , -1, . ${parameter#word} ${parameter##word} Remove matching prefix pattern. word , , parameter , . parameter, parameter ( "#" ) ( "##" ). parameter @ *, , . parameter @ *, , - . ${parameter%word} ${parameter%%word} Remove matching suffix pattern. word , , parameter , . parameter, parameter ( "%" ) ( "%%" ). parameter @ *, , . parameter @ *, , - . ${parameter/pattern/string} ${parameter//pattern/string} ${parameter/#pattern/string} ${parameter/%pattern/string} Pattern substitution. pattern parameter, . pattern string. string , , , , . . , parameter pattern ( ), pattern string. pattern # ( ), parameter. pattern % ( ), parameter. string , pattern , /, pattern, . patsub_replacement shopt, & string pattern. string , , . & string ; , & . ; \\ . , string , , . & string; &, , , &, , . , , , , , , , , . nocasematch, . parameter @ *, . parameter @ *, , . ${parameter^pattern} ${parameter^^pattern} ${parameter,pattern} ${parameter,,pattern} Case modification. parameter. pattern , . Bash parameter pattern, . , . . "^" , pattern , ; "," . ^ , , pattern; ^^ ,, , pattern. pattern , ?, . parameter @ *, , . parameter @ *, , . ${parameter@operator} Parameter transformation. parameter, parameter, operator. operator : U , parameter, , . u , parameter, , . L , parameter, , . Q , parameter, , , . E , parameter , $'...'. P , parameter, ( ). A declare, parameter . K , , parameter, , -, ( ). , . a , , parameter. k K, . parameter @ *, . parameter @ *, . , . Command substitution . : $(command) () `command`. Bash , command , . , . $(cat file) , $(< file). , , $, ` \. , , . $(command) , , ; . : ${c command;} command , . c, , , , |, , (.. : ). Bash , . command (, exit ). : , , return command; , , . , , |, REPLY command, , command , . Bash REPLY command REPLY , , command, . . , . , bash . . : $((expression)) expression , , expression . , . . , Bash , , , 0. . , . expression , bash , , . Process substitution , . <(list) >(list). list , . , , . >(list), list. <(list), list. < > , . , (FIFOs) /dev/fd. , . , , , word splitting. , , . IFS , . IFS whitespace - , ( ), IFS. , , space . IFS , , , IFS. IFS , , (. ) . IFS , . IFS IFS, IFS , , IFS , . IFS , , IFS, , IFS, . , , IFS, . IFS . ("" '') . , , , . , , , . , , , , , . "-d''" "-d" . , -f, bash *, ? [. , pattern , ( ), GLOBSORT. , nullglob , . nullglob , , . failglob , bash . nocaseglob, . , "." , dotglob. . .., "." (, ".?"), dotglob. globskipdots , . .. , ".". , "." . , , . shopt nocaseglob, nullglob, globskipdots, failglob dotglob. GLOBIGNORE , pattern. GLOBIGNORE, , GLOBIGNORE, . nocaseglob, GLOBIGNORE . . .. , GLOBIGNORE. GLOBIGNORE dotglob, , "." . , ".", ".*" GLOBIGNORE. dotglob , GLOBIGNORE . GLOBIGNORE extglob. GLOBSORT , . , , , , . NUL . ; . , . : * , . globstar * , *, , . /, * . ? . [...] , . bracket expression . , , range expression; , , , . , [, ! ^, , . -, . ], . , , , , LC_COLLATE LC_ALL. , [a-d] [abcd], LC_COLLATE LC_ALL C globasciiranges. , , character classes [:class:], class - , POSIX alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit , . word , _. , , equivalence class [=c=], ( ), c. , , [.symbol.] symbol. extglob shopt, . pattern-list - , |. : ?(pattern-list) . *(pattern-list) . +(pattern-list) . @(pattern-list) . !(pattern-list) , . extglob , . , , extglob , , . dotglob : dotglob, , ".", but . .. , ; , , "." ".". globskipdots , . .. . , "." . , , . . \, ' ", , . , . redirected , , , , . exec . simple command command. , , . , , varname. , >&- <&-, , 10 varname. varname >&- <&-, varname , . {varname}, , exec. varredir_close . , , "<", ( 0). ">", ( 1). , word , , , , , , , , . , bash . . , ls > dirlist 2>&1 , dirlist, ls 2>&1 > dirlist dirlist, , dirlist. Bash , , . , bash, , bash ; , . /dev/fd/fd fd , fd. /dev/stdin 0 . /dev/stdout 1 . /dev/stderr 2 . /dev/tcp/host/port host - , port - , bash TCP. /dev/udp/host/port host - , port - , bash UDP. . , 9, , , . , word n ( 0), n . : [n] , word n ( 1), n . , ; , . : [n]>word > noclobber set, , , word, . >| >, noclobber set , bash , , word . , word n, ( 1), n . , . : [n]>>word ( 1), ( 2) , word. : &>word >&word . >word 2>&1 word -. , , , ( ). ( 1), ( 2) , word. : &>>word >>word 2>&1 ( ). " " (Here Documents) , , delimiter ( ). , , ( n, n) . here-documents : [n]<<[-]word here-document delimiter , , word. - word , delimiter word here-document . word , delimiter - word here-document , : here-document , , \ , \ \, $ `; . <<-, , delimiter. . , \ : , - . here-document, , . " " (Here Strings) : [n]<< word , , , . . ( n, n). [n]<&word . word , n . , word , . word -, n . n , ( 0). [n]>&word . n , ( 1). word , , . word -, n . , n , word -, , . [n]<&digit- digit n ( 0), n . digit n. , [n]>&digit- digit n ( 1), n . [n]<>word , word, , n 0, n . , . Aliases , , . , alias unalias ( ). , , . , , . , , . /, $, ` =, metacharacters . , . , , , . , , , ls ls -F bash . blank, . alias, unalias. . , ( ). , , expand_aliases shopt ( shopt ). , , . Bash , , . , . , , , , , , , . , . . , , . , , , , . alias . . , , , , . , , . ; ( ). , . # , . 0 . FUNCNAME . , : DEBUG RETURN ( ), trace ( declare ) , -o functrace set ( DEBUG RETURN), ERR , -o errtrace. , , local ( local variables). . local , ( , ). current scope - . , "global" , . - , local declare . "shadow" , . , , , , , : , . , . dynamic scoping . , . , , , , , . , , . , var func1, func1 func2, var, func2, var func1, var. unset : , unset ; unset , , . , ( unset) , . , . unset , , , ( , localvar_unset ). FUNCNEST, , 0, . , , . return, . return , - ; - , return. , RETURN, . , # , . -f declare typeset . -F declare typeset (, , , extdebug). , (.. , ) -f export. -f unset . . FUNCNEST . bash . ( let declare, ((, for, [[ ). , , 0 . , , , . . . id++ id-- ++id --id - + ! ~ ** * / % , , + - , << >> <= >= < > == != & ^ | && || expr?expr:expr () = *= /= %= += -= <<= >>= &= ^= |= , expr1 , expr2 ; . , . , "x", x - , . , , 0, . , , integer declare -i . (null) 0. , integer . , . , 0, . 0x 0XX . [base#]n, base - 2 64, , n - . base# , 10. n, , 9 , @ _ . base 36, 10 35. . , . [[ test [ . test [ ; , . , . . , . Bash , . , bash, , bash ; : - file /dev/fd/n, bash n. file /dev/stdin, /dev/stdout, /dev/stderr, bash 0, 1 2 . , , , . [[ posix, < > . posix, test ASCII. -a file , file . -b file , file . -c file , file . -d file , file . -e file , file . -f file , file . -g file , file set-group-id. -h file , file . -k file , file "sticky" . -p file , file (FIFO). -r file , file . -s file , file . -t fd , fd . -u file , file set-user-id. -w file , file . -x file , file . -G file , file . -L file , file . -N file , file . -O file , file . -S file , file . -o optname , optname. -o set . -v varname (true), varname ( ). varname - @ *, true, - . varname - @ *, true, . -R varname , varname, . -z string , string . string -n string , string . string1 == string2 string1 = string2 (true), . = test POSIX [[ , ( ). string1 != string2 , . string1 < string2 , string1 string2. string1 > string2 , string1 string2. file1 -ef file2 , file1 file2 . file1 -nt file2 , file1 ( ), file2 file1 , file2 . file1 -ot file2 , file1 , file2 file2 , file1 . arg1 OP arg2 OP -eq, -ne, -lt, -le, -gt -ge. true, arg1 , , , , , arg2, . arg1 arg2 . [[ arg1 arg2 ( ). , [[ arg1 arg2, , , 0. , , . 1. , (.. , ) , . 2. , , . - , , - . 3. , , . 4. = , , , , . . ( ) . . , , . , . . , , . . , . , . , , . , . , , . , . , . , , bash PATH , . Bash - ( hash ). Bash PATH , -. , command_not_found_handle. , . , , 127. , . 0 , , . - , , , - shell script, .. , . Bash , , . , , , , , ( . , #!, . , . , , , , . execution environment, : o , , exec. o , cd, pushd popd . o umask . o , trap. o , set . o , . o ( , ), set. o , shopt. o , alias. o ID, , $$ PPID. , , , . , . o , , . o . o . o , , , , . o , , , , , , . , , . subshell - . , , , , , , , , . , , , , lastpipe, . , , . posix, , , -e . posix, bash -e . inherit_errexit , , , posix. & , /dev/null. , . , environment. name-value name=value. . , . . export, declare -x unset , . , , . , , , , , unset export -n, , export declare -x. - , , simple command, , . , . , . -k ( set ), , , . bash , _ . - , waitpid . () 0 255, , , 125. . . , , , . , , . N, bash 128+N . , , , 127. , , 126. - , . 0 (true) (false), . , 2, , , . ( ) $?. Bash , , , . exit . bash , - , SIGTERM ( kill 0 ) SIGINT ( wait ). bash SIGINT, . bash SIGQUIT. , bash SIGTTIN, SIGTTOU SIGTSTP. trap , . , , bash, , , trap . , SIGINT SIGQUIT , . , , SIGTTIN, SIGTTOU SIGTSTP. SIGHUP. SIGHUP , . SIGCONT , , SIGHUP ( ). , disown ( ) , SIGHUP disown -h. huponexit shopt, bash SIGHUP . bash , , , . bash wait , , wait , 128, . bash , , , SIGINT ( ^C), . , , ^C SIGINT . bash , , . bash , , , , . , bash . . bash SIGINT , , , SIGINT: 1. - SIGINT, bash , SIGINT SIGINT (, SIGINT, ). 2. SIGINT, SIGINT . bash SIGINT , , SIGINT (, emacs ) . , bash, , , SIGINT, , , . , bash , , SIGINT, . SIGINT, , . , - SIGINT, bash , SIGINT ( 1 ), . Job control (, suspend) (resume) . , , , bash. job . , jobs. job number, jobs . 1. bash ( background), , : [1] 25647 , 1 , , 25647. . Bash job . , process group ID current terminal process group ID. controlling terminal. , , process group. foreground (, ) , , SIGINT. foreground . Background , ; , . /, "stty tostop", . SIGTTIN (SIGTTOU) , "tostop" , , , . , bash, , bash . suspend ( ^Z, Control-Z) bash. delayed suspend ( ^Y, Control-Y) bash. , bg, , fg, , kill, . , . , , SIGSTOP kill. . % (jobspec). n %n. , , , . , %ce , ce. , %?ce , ce . , bash . %% %+ , current job. % ( ) . %- previous job. , , , , . , , . , . , %+, %-. , (, jobs), +, - -. , : %1 - "fg %1", 1 . , "%1 &" 1 , "bg %1". , . bash , , , , , . -b set , bash . Bash SIGCHLD , . bash , bash . jobs, wait , , . , 1. bash (, checkjobs shopt, , checkjobs , . jobs . , , bash . , wait , wait . -f wait . bash PS1, PS2, . Bash PROMPT_COMMAND . - PROMPT_COMMAND , Bash , . Bash PS0 , . Bash PS4, , , -x. Bash PS0, PS1, PS2 PS4, , , : \a ASCII (07). \d "Weekday Month Date" (, "Tue May 26"). \D{format} format strftime(3), ; format , . . \e ASCII (033). \h ".". \H . \j , . \l (, "ttys0"). \n . \r . \s : $0 (, ). \t 24- ::. \T 12- ::. \@ 12- / . \A 24- :. \u . \v bash (, 2.00). \V bash, + (, 2.00.0) \w PWD ($PWD), $HOME ( PROMPT_DIRTRIM). \W $PWD, $HOME . \! . \# . \$ UID 0, A #, $. \nnn , nnn. \\ . \[ , . \] . : - , , ( ), - . , , , , , promptvars ( shopt ).. , , . READLINE , , --noediting. -e read. emacs; vi. , -o emacs -o vi set ( ). , +o emacs +o vi set. Readline Emacs . C-key, , C-n Control-N. , meta M-key, M-x -X. - "Alt" "Option". Meta M-x ESC x, .. Escape, x. , ESC meta prefix. M-C-x ESC Control-x: Escape, Control, x, . - (0200). enable-meta-key, , , . - , ESC, . Meta - ESC, M-key, ( Readline ), , force-meta-prefix. Readline arguments, . . , (, kill-line) . , . point - , mark . region. Readline active region: , readline , active-region-start-color. enable-active-region . ; . killing, ( "" yanking). () kill ring. , . , , . Readline Readline ( inputrc). INPUTRC. , ~/.inputrc. , readline /etc/inputrc. , readline, readline , . inputrc . . , #, . , $, . . inputrc. , readline, bash, . , M-Control-u: C-Meta-u: inputrc M-C-u readline universal-argument. : DEL, ESC, ESCAPE, LFD, NEWLINE, RET, RETURN, RUBOUT ( ), SPACE, SPC TAB. , readline , (macro). , . Readline inputrc . , , - , . : 1) , , Meta- Control- 2) , , . . . keyname:function-name macro, keyname - . : Control-u: universal-argument Meta-Rubout: backward-kill-word Control-o: "> output" C-u universal-argument, M-DEL backward-kill-word, C-o , ( "> output" ). , "keyseq":function-name macro, keyseq keyname , , , . GNU Emacs, , . "\C-u": universal-argument "\C-x\C-r": re-read-init-file "\e[11~": "Function Key 1" C-u universal-argument. C-x C-r re-read-init-file, ESC [ 1 1 ~ "Function Key 1". escape- GNU Emacs, , \C- . \M- - -, -. \e . \\ . \" ", . \' ', . GNU Emacs : \a () \b \d delete \f \n newline \r \t \v \nnn , nnn ( ). \xHH , HH ( ). . , . . , " '. Bash readline bind. -o emacs -o vi set ( ) . Readline Readline , . inputrc set variable-name value bind ( ). , , readline "" On "" Off ( ). . readline , , "on" ( ) "1" On. Off. bind -V readline ( ). : active-region-start-color , ( enable-active-region ). , escape-. . . - , , terminfo. "\e[01;33m". active-region-end-color , "undoes" " - " active-region-start-color "normal" . , . . . , , terminfo. "\e[0m". bell-style (audible) , , readline . none, readline . visible, readline , . audible, readline . bind-tty-special-chars (On) On, readline , , readline. readline . "stty -a" bash, , ( cchars). blink-matching-paren (Off) On, readline . colored-completion-prefix (Off) On, readline , . LS_COLORS. $LS_COLORS ".readline-colored-completion-prefix", readline . colored-stats (Off) On, readline , , . LS_COLORS. comment-begin ( "#") , readline insert-comment. M-# emacs # vi. completion-display-width (-1) , . , 0 . 0 . -1. completion-ignore-case (Off) On, readline . completion-map-case (Off) On "- ", readline (-) (_) . completion-prefix-display-length (0) , . , , readline , , . , readline , . completion-query-items (100) , , possible-completions. , . , readline , ; readline . , readline ; . convert-meta (On) On, readline , , ASCII, escape- ( -). - On, readline Off, , . LC_CTYPE . ; - . disable-completion (Off) On, readline . , self-insert. echo-control-characters (On) On, , , , readline , , . editing-mode (emacs) , readline , Emacs vi. editing-mode emacs, vi. emacs-mode-string (@) show-mode-in-prompt, , emacs. , - , escape- . \1 \2 , . enable-active-region (On) On, readline active. , readline , active-region-start-color, , . , , . enable-bracketed-paste (On) On, readline , , . " " bracketed-paste mode; readline , , . enable-keypad (Off) On, readline . . enable-meta-key (On) On, readline -, , , . - ; , , , (0200), - (). expand-tilde (Off) On, readline . force-meta-prefix (Off) On, readline , \M- Meta- ( ), \M-C Meta-C ESC C ( meta). force-meta-prefix Off ( ), readline convert-meta , , : convert-meta On, readline , ; Off, readline C , (0200). history-preserve-point (Off) On, , previous-history next-history. history-size (unset) , . , , . , . bash HISTSIZE. history-size , 500. horizontal-scroll-mode (Off) On readline , , . 1. input-meta (Off) On, readline ( ), , , , . - Off, readline On, , . LC_CTYPE . meta-flag input-meta. isearch-terminators ( "C-[C-j") , . , ESC C-j . keymap (emacs) readline. emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-command vi-insert; emacs emacs-standard. - emacs; " " editing-mode . keyseq-timeout (500) , readline ( , ). readline -, , . , 1000 , readline . , , readline , , . mark-directories (On) On, . mark-modified-lines (Off) On, readline , , (*). mark-symlinked-directories (Off) On, , , , mark-directories. match-hidden-files (On) , On, readline , "." ( ) . Off, "." , . menu-complete-display-prefix (Off) On, ( ) . output-meta (Off) On, readline , escape- -. - Off, readline On, , . LC_CTYPE . page-completions (On) On, readline , more(1), , . prefer-visible-bell bell-style. print-completions-horizontally (Off) On, readline , , . revert-all-at-newline (Off) On, readline , accept-line. readline. search-ignore-case (Off) On, readline . show-all-if-ambiguous (Off) . On, , , , . show-all-if-unmodified (Off) show-all-if-ambiguous. On, , - ( ), , . show-mode-in-prompt (Off) On, , : emacs, vi. (, emacs-mode-string). skip-completed-text (Off) On, . . , readline , , , , . vi-cmd-mode-string ((cmd)) show-mode-in-prompt, , vi . , - , escape- . \1 \2 , . vi-ins-mode-string ((ins)) show-mode-in-prompt, , vi . , - , escape- . \1 \2 , . visible-stats (Off) On, , , stat(2). Readline Readline , C, . . $if $if , , readline. ; , . mode mode= $if , readline emacs vi. set keymap, , emacs-standard emacs-ctlx, readline emacs. term term= , , , , . , =, , -. , , xterm xterm, xterm-256color. version version readline. version readline. =, ( ==), !=, <=, >=, < >. , , , (, 7.1). , 0. version . application application , . , readline, application name . , . , , bash: $if Bash # "\C-xq": "\eb\"\ef\"" $endif variable variable readline. =, == !=. ; . . "" on "" off. $else $if . $endif , , $if. $include . , /etc/inputrc: $include /etc/inputrc Readline , , ( ). : incremental non-incremental. , . readline , . , . emacs C-r, . C-s () . , isearch-terminators, . , ESC C-j . C-g . , , , . , C-r C-s, . , . , readline, . , , . , . Readline . C-r - , , readline . , . . Readline , . . "" point , "" mark - , set-mark. region. Readline active region: , readline , active-region-start-color. readline enable-active-region . ; . beginning-of-line (C-a) . Home. end-of-line (C-e) . End. forward-char (C-f) . . backward-char (C-b) . . forward-word (M-f) . - ( ). backward-word (M-b) . - ( ). shell-forward-word (M-C-f) . , . shell-backward-word (M-C-b) . , . previous-screen-line . , readline . next-screen-line . , readline readline . clear-display (M-C-l) , , , , . clear-screen (C-l) , , . , , . redraw-current-line . accept-line (Newline, Return) , . , HISTCONTROL HISTIGNORE. , . previous-history (C-p) , . . next-history (C-n) , . . beginning-of-history (M-<) . end-of-history (M->) , .. , . operate-and-get-next (C-o) , . , , , . fetch-history , . , . reverse-search-history (C-r) , "up" . . . forward-search-history (C-s) , "down" . . . non-incremental-reverse-search-history (M-p) , , , . . non-incremental-forward-search-history (M-n) , , . . history-search-backward . . . Page Up key (" ") . history-search-forward . . . Page Down (" "). history-substring-search-backward . . . history-substring-search-forward . . . yank-nth-arg (M-C-y) ( ) . n n- ( 0). n- . n , n- , "!n" . yank-last-arg (M-., M-_) ( ). , yank-nth-arg. yank-last-arg , ( , ) . , , . ( ). , "!$" . shell-expand-line (M-C-e) . , $'string' $"string", , , , , . . . history-expand-line (M-^) . . magic-space . . alias-expand-line . . history-and-alias-expand-line . insert-last-argument (M-., M-_) yank-last-arg. edit-and-execute-command (C-x C-e) . Bash $VISUAL, $EDITOR emacs . end-of-file (usually C-d) , , , , stty(1). , , , readline EOF. delete-char (C-d) . , tty EOF, C-d, , . Delete . backward-delete-char (Rubout) , . , . forward-backward-delete-char , , , , . quoted-insert (C-q, C-v) . , , , C-q. tab-insert (C-v TAB) . self-insert (a, b, A, 1, !, ...) . bracketed-paste-begin "bracketed paste" escape-, . readline , , . , self-insert - . . transpose-chars (C-t) , . , . . transpose-words (M-t) , . , . shell-transpose-words (M-C-t) , . , . , shell-forward-word shell-backward-word. upcase-word (M-u) ( ) . , , . downcase-word (M-l) ( ) . , , . capitalize-word (M-c) ( ) . , . overwrite-mode . . . emacs; vi -. readline() . , self-insert, , . , backward-delete-char, . , "Insert" . kill-line (C-k) . , . backward-kill-line (C-x Rubout) , . . unix-line-discard (C-u) , . kill-whole-line , , . kill-word (M-d) , , . , forward-word. backward-kill-word (M-Rubout) , . , backward-word. shell-kill-word (M-C-d) , , . , shell-forward-word. shell-backward-kill-word , . , shell-backward-word. unix-word-rubout (C-w) , , . unix-filename-rubout , , . delete-horizontal-space (M-\) . kill-region . copy-region-as-kill , . copy-backward-word . backward-word. copy-forward-word , , . , forward-word. yank (C-y) . yank-pop (M-y) . yank yank-pop. digit-argument (M-0, M-1, ..., M--) . M - . universal-argument . universal-argument , , . universal-argument , , . , , , , . , , . complete (TAB) . Bash , - ( ), ( $), ( ~)., ( @) ( , ) . , . possible-completions (M-?) . readline , , completion-display-width, COLUMNS , . insert-completions (M-*) , possible-completions, . menu-complete complete, , , . menu-complete , . menu-complete ( bell-style) . n n ; . TAB, . menu-complete-backward menu-complete, , menu-complete . . export-completions , readline, : o N; o ; o S:E, S E readline; o , , "0", S:E. , , . , S , :E, . N . . , N , S:E, . . delete-char-or-list , (, delete-char). possible-completions. . complete-filename (M-/) . possible-filename-completions (C-x /) , . complete-username (M-~) , . possible-username-completions (C-x ~) , . complete-variable (M-$) , . possible-variable-completions (C-x $) , . complete-hostname (M-@) , . possible-hostname-completions (C-x @) , . complete-command (M-!) , . , , , , , . possible-command-completions (C-x !) , . dynamic-complete-history (M-TAB) , . dabbrev-expand , . complete-into-braces (M-{) , , ( ). start-kbd-macro (C-x () , . end-kbd-macro (C-x )) , . call-last-kbd-macro (C-x e) , , , . print-last-kbd-macro () , inputrc. re-read-init-file (C-x C-r) inputrc . abort (C-g) ( bell-style). do-lowercase-version (M-A, M-B, M-x, ...) x , , . , x . prefix-meta (ESC) . ESC f, Meta-f. undo (C-_, C-x C-u) , . revert-line (M-r) , . undo , . tilde-expand (M-&) . set-mark (C-@, M-) . , . exchange-point-and-mark (C-x C-x) . , . character-search (C-]) . . character-search-backward (M-C-]) . . skip-csi-sequence , , , , Home End. CSI (CSI), ESC [. "\e[", , CSI, , readline, . , ESC [. insert-comment (M-#) , readline comment-begin . , : comment-begin, ; comment-begin . , . comment-begin , . , . spell-correct-word (C-x s) , , , cdspell . , shell-forward-word. glob-complete-word (M-g) , . glob-expand-word (C-x *) , . , * . glob-list-expansions (C-x g) , glob-expand-word . , * . dump-functions readline. , , inputrc. dump-variables readline readline. , , inputrc. dump-macros readline, , readline. , , inputrc. execute-named-command (M-x) readline , , , , . , , . display-shell-version (C-x C-v) bash. , compspec complete ( ), readline . -, bash . , . ( ), bash , -E complete. -I complete , , , ; |. . , bash . , bash , . , bash , -D complete . , bash , . , bash , . , , bash . bash actions, . , . -f -d, bash FIGNORE . , , , -G. , , . Bash FIGNORE , GLOBIGNORE. , -W. IFS . , , IFS. , , , , . , . , . , , bash , -F -C. , bash COMP_LINE, COMP_POINT, COMP_KEY COMP_TYPE, . , bash COMP_WORDS COMP_CWORD. , ($1) - , , ($2) - , ($3) - . ; . , -F. , compgen compopt, . COMPREPLY, . , , -C, , . , . . . , bash , -X, . , ; & . & ; . , , . ! ; bash , . nocasematch, bash . , , -P -S, , readline . - , -o dirnames complete , bash . -o plusdirs complete , bash . , , , , . bash readline . -o bashdefault complete , bash . , , bash , -o default complete , readline . , complete compopt, , readline . , -o fullquote readline , . complete . , , readline , , mark-directories readline, mark-symlinked-directories readline. . , complete -D. , , , , , 124. 124 , , ( ), . , . , , , , , : _completion_loader() { . "/etc/bash_completion.d/$1.sh".if 0<80n \ >/dev/null 2>&1 && return 124 } complete -D -F _completion_loader.if 0<80n \ -o bashdefault -o default -o history set, command history, . . . HISTSIZE : HISTSIZE ( 500). ( ), , , HISTIGNORE HISTCONTROL. bash , , HISTFILE ( ~/.bash_history). history file. , , HISTFILESIZE. HISTFILESIZE , , , . , , , . HISTTIMEFORMAT. , , , . , bash $HISTSIZE $HISTFILE. histappend ( shopt ), bash , . HISTFILE , , . , bash , HISTFILESIZE , . HISTTIMEFORMAT, , , , , , . , . , HISTTIMEFORMAT . fc ( ) . history . , . , . HISTCONTROL HISTIGNORE . cmdhist , , , , . lithist cmdhist, . shopt . , csh. . +H set ( ). , "set -H". , , . , , , . , . . , . - . , , event, , , words. modifiers. , , , , metacharacter , . event designator , word designator , modifiers . , !. , . (\) , , , . , , ; - , , , , = , . , , quick substitution ( histchars) . , , !! . . , . , shopt, ( shopt ). histverify readline, . readline . readline histreedit, readline . -p history , . -s history , . , ( histchars ). . - . , , , . , . ! , , blank, , , = , extglob shopt, (. !n n. !-n n. !! . "!-1". !string , , string. !?string[?] , , string. ? , string . string , ; , . ^string1^string2^ . , string1 string2. "!!:s^string1^string2^" ( ). !# . . ; , . : . , ^, $, *, - %. , 0 (). . 0 (zero) . . n n. ^ : word 1. $ . , , . % , "?string?" , , . , . x-y ; "-y" "0-y". * , . "1-$". *, , ; . x* x-$. x- x-$ x*, . x , 0. , , !!. , , ":". , . h , . t , . r .xxx, . e , . p , . q , . x , q, blanks . q x ; . s/old/new/ old new . / . , . old new . new &, old. & . old , old , , string !?string[?]. new , old . & . g . ":s" (, ":gs/old/new/") ":&". ":s", / , , . a g. G "s" "&" . , , , -, -- . : true, false test/[ -- . exit, logout, return, break, continue, let shift , -, --. , , , , -, -- . : [arguments] ; , arguments . . . [-p path] filename [arguments] source [-p path] filename [arguments] . (source) filename , filename. filename , . . -p, . path , , filename; . PATH, , filename. filename . bash posix, , filename PATH, , -p. sourcepath shopt , . PATH. - arguments, filename. . -T , . DEBUG; , DEBUG ., . DEBUG . -T , DEBUG, .. - , filename (0, ) , filename . alias [-p] [name[=value] ...] -p, alias alias name=value . , name, value. value , . name , value, name. alias true, name ( =value), . bg [jobspec ...] jobspec , &. jobspec , current job. bg jobspec 0, ( ) , jobspec . bind [-m keymap] [-lsvSVX] bind [-m keymap] [-q function] [-u function] [-r keyseq] bind [-m keymap] -f filename bind [-m keymap] -x keyseq[:] shell-command bind [-m keymap] keyseq:function-name bind [-m keymap] -p|-P [readline-command] bind [-m keymap] keyseq:readline-command bind readline-command-line readline, readline readline. , , , readline .inputrc, ; , *'"\C-x\C-r": re-read-init-file'. , , , readline bind. , , : -m keymap keymap , . keymap emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command vi-insert. vi vi-command (vi-move ); emacs emacs-standard. -l readline. -p readline , bind readline. , bind readline . -P readline. , bind readline . -s readline, , , , bind readline. -S readline, , , . -v readline , bind readline. -V readline. -f filename filename. -q function , readline function. -u function , readline function. -r keyseq keyseq. -x keyseq[: ]shell-command , shell-command , keyseq. keyseq shell-command , , . , shell-command , readline shell-command . , , readline . , . shell-command, READLINE_LINE readline, READLINE_POINT READLINE_MARK - . (), . , , READLINE_ARGUMENT. , . READLINE_LINE, READLINE_POINT READLINE_MARK, . -X , , , bind. 0, . break [n] for, while, until select. n, break , n. n >= 1. n , , . 0, n 1. builtin shell-builtin [arguments] shell-builtin, arguments . , , . cd . false, shell-builtin . caller [expr] ( , . source). expr, caller . expr , caller , , . , , . 0. 0, expr . cd [-L] [-@] [dir] cd -P [-e] [-@] [dir] dir. dir , HOME dir. CDPATH dir (/), cd : CDPATH dir. CDPATH (:). CDPATH , .., ".". -P cd , dir .. dir ( -P set). -L cd , .. dir. .. dir, cd , dir, dir , dir, , . , cd . -L, -P, cd , -L. -e -P, cd , . , , -@ , , . - $OLDPWD . cd CDPATH - , , cd . , cd PWD , OLDPWD . true, ; - false. command [-pVv] command [arg ...] command command args, command. , PATH command. -p, command PATH, . -V -v, command command. -v , , command; -V . -V -v, , command , . command , 127. command command. compgen [-V varname] [option] [word] word option, , complete, -p, -r, -D, -E -I . -V, compgen varname , . -F -C , , , . , . word, , word. true, . complete [-abcdefgjksuv] [-o comp-option] [-DEI] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] name [name ...] complete -pr [-DEI] [name ...] , name. -p , name, , . -r name , name , . -D , "default" ; , . -E , "empty" ; . -I , , , , ; |, . , -D -E, -I. - -D, -E -I, name ; , . above under Programmable Completion. , , . -G, -W -X (, , -P -S) , complete. -o comp-option comp-option compspec, . comp-option : bashdefault bash, compspec . default readline, . dirnames , (compspec) . filenames readline, , , (, , ). . fullquote readline , . noquote readline, , ( ). nosort readline, . nospace readline, ( ) , . plusdirs , , . -A action action : alias . -a. arrayvar . binding Readline. builtin . -b. command . -c. directory . -d. disabled . enabled . export . -e. file , readline. -f. function . group . -g. helptopic , help. hostname , , HOSTFILE. job , . -j. keyword . -k. running , . service . -s. setopt -o set. shopt , shopt. signal . stopped . . user . -u. variable . -v. -C command command , . , -F. -F function function . , ($1) - , , ($2) - , ($3) - , . function , COMPREPLY. -G globpat globpat, . -P prefix prefix , . -S suffix suffix , . -W wordlist wordlist, IFS . wordlist , , IFS. , . -X filterpat filterpat - , . , , , filterpat, . ! filterpat ; , filterpat, . true, , -p, -r, -D, -E, -I, name, name, , . compopt [-o option] [-DEI] [+o option] [name] name option , name. option, name . option complete, . -D , "default" ; -E , "empty" ; -I , . , complete. , -D -E, -I. true, , name, , . continue [n] continue for, while, until select. n, bash n- . n >= 1. n , , ( "top-level" ). 0, n 1. declare [-aAfFgiIlnrtux] [-p] [name[=value] ...] typeset [-aAfFgiIlnrtux] [-p] [name[=value] ...] / . name , . -p name. -p name, , -f -F, . -p name, declare , , . -p , declare . -f . -F ; . extdebug shopt, , name. -F -f. -g , declare . , declare . -I , ( nameref) name . , . , : -a name ( above). -A name ( above). -f name . -i ; ( above) , . -l , . . -n name nameref, . name. , name, , -n, , name. nameref . -r name . . -t name trace. DEBUG RETURN . trace . -u , . . -x name . "+" "-" , , +a +A , +r . , declare typeset name , local, -g. =value, value. -a -A , . 0, , "-f foo=bar", , , ( above), names , , -f. dirs [-clpv] [+n] [-n] . , . pushd; popd . . , , : -c , . -l ; . -p . -v , . +n n- , , dirs , . -n n- , , dirs , . 0, n . disown [-ar] [-h] [id ...] , id . id jobspec pid; id pid, disown , pid, jobspec. -h, disown , id, , , SIGHUP , SIGHUP. id , -a ; -r id . id -a, -r, disown . 0, id . echo [-neE] [arg ...] arg, , . 0, . -n, . -e, echo , . -E , . xpg_echo , - echo escape. echo -- . echo escape: \a () \b \c \e \E \f \n \r \t \v \\ \0nnn , nnn ( ). \xHH , HH ( ). \uHHHH Unicode (ISO/IEC 10646), HHHH ( ). \UHHHHHHHH Unicode (ISO/IEC 10646), HHHHHHHH ( ). echo , , . enable [-a] [-dnps] [-f filename] [name ...] . , , , . -n, name ; name . , test, PATH, , "enable -n test". name -p, . . -n, . -a, , . -s POSIX special . -f name filename , . filename , Bash BASH_LOADABLES_PATH , , filename. BASH_LOADABLES_PATH "." . -d , -f. -s -f, POSIX . name , enable name name, "enable -f name name". 0, name . eval [arg ...] arg , . Bash eval. args , eval 0. exec [-cl] [-a name] [command [arguments]] command, . command . arguments command. -l, , command. , login(1). -c , command . -a, name . - command , , execfail. . , . , exec . command , , 0. , 1. exit [n] n. n , . EXIT . export [-fn] [name[=value]] ... export -p [-f] names . -f, names . -n export name. names -p, export . -p -f . -p , . export , =value. value, "export" . export , 0, , names -f name, . false ; . fc [-e ename] [-lnr] [first] [last] fc -s [pat=rep] [cmd] first last . First last ( , ) ( , ). first last, 0, -1, -0 ( fc); 0 -1, -0 . last , ( "fc -l -10" 10 ), , first. first , , -16. -l, . -n . -r . fc ename , . ename , fc FCEDIT EDITOR, FCEDIT . , fc vi. , fc , -, . fc command pat rep. Command , first . fc "r=fc"-s(dq" "r cc" , "cc" "r" . , , first last . (failure), . , , cmd , fc . fg [jobspec] jobspec . jobspec , fg current job. , , , , jobspec , jobspec , . getopts optstring name [arg ...] getopts . optstring , ; , , , . . , , getopts name, name, OPTIND. OPTIND 1 . , getopts OPTARG. OPTIND ; getopts , . , getopts , . OPTIND , , name ?. getopts , arg , getopts . getopts . optstring , getopts "" silent . getopts . OPTERR 0, getopts , optstring . getopts , ? name , "" (silent) , OPTARG. "" , getopts OPTARG . , getopts "" , getopts name (?), OPTARG . getopts "", name (:), OPTARG - . getopts true, . false, . hash [-lr] [-p filename] [-dt] [name] , hash, name, $PATH. , name, . -p, hash filename . -r , . PATH . -d , "" name. -t, hash , name. name -t, hash name . -l , . -l, hash . -t, -d -p (, name) . . , -t , -p , -d. , name . help [-dms] [pattern] . pattern , help , , ; . , , : -d pattern -m pattern , (manpage) -s pattern pattern , ( ), help , pattern. , pattern , help , . help . 0, pattern. history [n] history -c history -d offset history -d start-end history -anrw [filename] history -p arg [arg ...] history -s arg [arg ...] , . , *, . n n . HISTTIMEFORMAT , strftime(3) , . history HISTTIMEFORMAT, . filename, history ; , HISTFILE. filename , HISTFILE , -a, -n, -r -w . , , : -c , . . -d offset offset. offset , , , , , -1, history -d. -d start-end start end . start end , . -a "new" . , bash, . -n , . , bash. -r . -w , . -p args , . arg , . -s args . args. HISTTIMEFORMAT, history , , , , . , , , . 0, , , -d offset , -p. jobs [-lnprs] [ jobspec ... ] jobs -x command [ args ... ] . : -l . -n , . -p . -r . -s . jobspec, jobs . 0, jobspec. -x, jobs jobspec, command args, command, args . kill [-s sigspec | -n signum | -sigspec] id [ ... ] kill -l|-L [sigspec | exit_status] , sigspec signum, , id. id jobspec pid. sigspec - , SIGKILL ( SIG ), ; signum - . sigspec , kill SIGTERM. -l . -l - , kill , , 0. exit_status -l - , , , ; , kill , . kill , 128; , , . -L -l. kill true, , false, . let arg [arg ...] arg ( above). arg 0, let 1; let 0. local [option] [name[=value] ... | - ] name value. option , declare. local , , name , . local . name , , local: , set, , local , . , set , . local . 0, local , name name , . logout [n] , n. mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] fd, -u, Iarray. MAPFILE array. , , : -d delim , . delim , mapfile , NUL. -n count. count 0, . -O array origin. 0. -s count. -t delim ( ) . -u fd . -C callback quantum. -c quantum. -c , callback. -C -c, 5000. " " callback , , , . callback , . , mapfile array . mapfile , array , array . popd [-n] [+n] [-n] . 0, , dirs, popd "popd +0." popd . , , : -n . +n n- , , dirs, . : "popd +0" , "popd +1" . -n n- , , dirs, . : "popd -0" , "popd -1" , . , -n , popd cd , . cd , popd . , popd false, , n . popd , bash dirs, , 0. printf [-v var] format [arguments] arguments format. -v var , . format - , : , , , , argument. printf(3) cCsSndiouxXeEfFgGaA, printf : %b , printf argument , echo -e. %q , printf argument , . %q %Q $'', - . printf, . %Q , %q, argument, . %(datefmt)T , printf , datefmt strftime(3). argument - , , . : -1 , -2 - . , , -1. printf. %b, %q %T ( ) , , . %n , . %s %c l (), , . %S %C %ls %lc, . , , , , . format arguments. format arguments, , , , . , . pushd [-n] [+n] [-n] pushd [-n] [dir] , . pushd . , , : -n , . +n , n- ( , dirs, ) . -n , n- ( , dirs, ) . dir dir . , -n , pushd cd , . cd , pushd . , , pushd , . pushd , n . pushd , bash dirs, . pwd [-LP] . , -P -o physical set. -L, . 0, . read [-Eers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] , fd -u, , above name, name . , , name. , , . IFS , ( above ). (\) . , , : -a aname aname, 0. aname - . name . -d delim delim , . delim , read , NUL. -e , read readline ( READLINE above) . Readline ( , ), Readline . -E , read readline ( READLINE above) . Readline ( , ), bash, . -i text readline, read text . -n nchars read nchars, , EOF read, , nchars. -N nchars read nchars , , EOF read. - read , nchars. IFS; , , ( ; -r ). -p prompt prompt , - , . -r . . , - . -s "" . , . -t timeout read , ( ) - timeout. - timeout , . , read , ; . read , , name, , 128. timeout 0, read , - . 0, , , read EOF, . -u fd read fd . , delim , read NUL . names , read , , REPLY. , - read ( 128), (, , ) -u. readonly [-aAf] [-p] [name[=word] ...] names ; names . -f, names . -a ; -A . , -A. name -p, , . , . -p , . readonly readonly , =value. value, readonly . 0, names -f name , . return [n] , n. n , . return , , , , . return DEBUG, , , , return. return , . (source), , n, , , . n, 8 . , RETURN, , . , return , . source. set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...] set [+abefhkmnptuvxBCEHPT] [+o option-name] [--] [-] [arg ...] set -o set +o , . , , . posix . . , . , , $1, $2, ..., $n. , , : -a export, . -b , . . -e , pipeline ( simple command), list compound command ( above), . , , , , while until, , if elif, , && ||, , && ||, , ( pipefail) !. , , - , -e , . ERR, . ( above), . , -e , , , -e, -e . -e , -e , , . -f . -h . . -k , , . -m . . , ( above). . , , . -n , . . . -o option-name option-name : allexport , -a. braceexpand , -B. emacs emacs. , , --noediting. , read -e. errexit , -e. errtrace , -E. functrace , -T. hashall , -h. histexpand , -H. history , above . . ignoreeof , "IGNOREEOF=10" ( above). keyword , -k. monitor , -m. noclobber , -C. noexec , -n. noglob , -f. nolog . notify , -b. nounset , -u. onecmd , -t. physical , -P. pipefail , ( ) , , , . . posix posix; bash, POSIX , . below , , posix bash. privileged , -p. verbose , -v. vi vi. , read -e. xtrace , -x. -o option-name, set . +o option-name, set set, . -p privileged. $ENV $BASH_ENV, , SHELLOPTS, BASHOPTS, CDPATH GLOBIGNORE, , . (), (), -p , . -p, . . -r . , . -t . -u , "@" "*", , "@" "*", . , , , . -v . -x simple command, for, case, select for PS4, , . -B ( above). . -C , bash >, >& <>. >| > . -E , ERR , , . ERR . -H !. , . -P , , cd, . . bash , . -T , DEBUG RETURN , , . DEBUG RETURN . -- , . arg -. - arg . -x -v . arg, . , . + - . . $-. , . shift [n] n+1 ... $1 .... , $# $#-n+1, . n , $#. n 0, . n , , 1. n , $#, . , n , $# ; 0. shopt [-pqsu] [-o] [optname ...] , . , , , -o, , -o set. -p , ; - optnames, . -p , . : -s () optname. -u () optname. -q ( ); , optname. optname -q, , optname; . -o optname , -o, set. -s, -u optname, shopt , . , shopt (unset). , optnames, . , optnames . shopt : array_expand_once , , , , , . assoc_expand_once ; array_expand_once. autocd , , , , cd. . bash_source_fullpath , , BASH_SOURCE, ( ). cdable_vars , , cd, , , . cdspell , cd . , . cd , . . checkhash , bash , , -, . - , bash . checkjobs , bash . - , bash , ( above). , - . checkwinsize , bash ( ) , , LINES COLUMNS, , , . . cmdhist , bash . . , , , above HISTORY. compat31 compat32 compat40 compat41 compat42 compat43 compat44 ( ) below). complete_fullquote , bash . , bash , , , , , . , , , ; , , . , bash . , bash 4.2. direxpand , bash . readline. , bash , . dirspell , bash , . dotglob , bash , "." . . .. , dotglob. execfail , , , exec. , exec . expand_aliases , , above . . extdebug , , --debugger. , , : 1. -F declare , , . 2. , DEBUG, , . 3. , DEBUG, 2, ( , . source), return. 4. BASH_ARGC BASH_ARGV above). 5. : , , ( command ), DEBUG RETURN. 6. : , , ( command ), ERR. extglob , above . extquote , $'string' $"string" ${parameter}, . . failglob , , , . force_fignore , , FIGNORE, , , . above FIGNORE. . globasciiranges , , ( above) , . , b A B, ASCII . globskipdots , . .., ".". . globstar , **, , . /, . gnu_errfmt , GNU. histappend , , HISTFILE, , . histreedit readline, . histverify readline, . readline, . hostcomplete readline, bash , @ ( READLINE above). . huponexit , bash SIGHUP . inherit_errexit , errexit, . , posix. interactive_comments , #, , ( above). . lastpipe , , , . lithist cmdhist, , , . localvar_inherit , , , - . nameref . localvar_unset , unset , , . . login_shell , ( above). . mailwarn , bash , , bash "The mail in mailfile has been read". no_empty_cmd_completion readline, bash PATH . nocaseglob , bash ( above). nocasematch , bash case [[, . noexpand_translation , bash $"... " . , . nullglob , , ( above) , . patsub_replacement , bash & , , above. . progcomp , ( above). . progcomp_alias , bash , , . , bash , , . promptvars , , , , above. . restricted_shell , ( below). . , , . shift_verbose , shift , . sourcepath , . (source PATH , , , -p . . varredir_close , , {varname} ( above) , . xpg_echo , echo, , escape- . posix , echo . suspend [-f] , SIGCONT. ; -f . 0, -f , . test expr [ expr ] 0 (true)) 1 (false) expr. . , above . test , -- . , . ; . test . ! expr expr . ( expr ) expr. . expr1 -a expr2 , expr1 expr2 . expr1 -o expr2 , expr1 expr2 . test [ , , . 0 . 1 argument , . 2 !, , . , above , , . , . 3 . above , . -a -o . !, . (, ), . . 4 . !, , . (, ), . , . 5 , . posix [[, < > . posix, test [ ASCII. 4- , . POSIX -a -o , . . -a -o && ||. times , . 0. trap [-lpP] [[action] sigspec ...] action - , , sigspec. action ( sigspec) -, sigspec , . action , , sigspec, . , trap , , trap, . -p, action , trap , sigspec , , trap, . -P , , sigspec. -P sigspec. -P -p (, ) , , trap , . -l . sigspec , , . , SIG . -l sigspec, . sigspec EXIT (0), action . sigspec DEBUG, action simple command, for, case, select, ((, [[, for ( above). extdebug ( shopt above) DEBUG. sigspec RETURN, action , , . source. sigspec ERR, action , ( ), , . ERR , , while until, if, , && || , , && ||, , ( pipefail) !. , errexit (-e). , , , . , . , , , . false, - sigspec ; trap true. true , 0. type [-aftpP] name [name ...] name, . -t, type , alias, keyword, function, builtin file, name , , , , . name , type . -p, type , , $PATH name, , "type -t name" file. -P PATH name, "type -t name" file. name , -p -P , , PATH. -a, type , name. , , , (-p -P), . type -a -p, PATH name. -f , command. type true, false, . ulimit [-HS] -a ulimit [-HS] [-bcdefiklmnpqrstuvxPRT [limit]] , , , . -H -S , . , root, ; . -H, -S, ulimit , . limit , hard, soft unlimited, , , . limit , ulimit , -H. , , . : -a ; . -b . -c . -d . -e ( "nice"). -f , . -i . -k k-, . -l , . -m ( ). -n ( ). -p 512- ( ). -q POSIX -r . -s . -t . -u , . -v , , , . -x . -P . -R , , . -T . limit, -a , limit. , -f. 1024 , -t, ; -R, ; -p, 512 ; -P, -T, -b, -k, -n -u, ; posix, -c -f, 512 . 0, . umask [-p] [-S] [mode] mode. mode , ; , , chmod(1). mode , umask . -S mode ; . -p, mode , , . , mode . unalias [-a] [name ...] name . -a, . true, , name . unset [-fv] [-n] [name ...] name . -v, name . -f, name . -n, name nameref, name , , . -n , -f. , , . , , . , name ; , , , . . - BASH_ALIASES, BASH_ARGV0, BASH_CMDS, BASH_COMMAND, BASH_SUBSHELL, BASHPID, COMP_WORDBREAKS, DIRSTACK, EPOCHREALTIME, EPOCHSECONDS, FUNCNAME, GROUPS, HISTCMD, LINENO, RANDOM, SECONDS SRANDOM , , . true, , name . wait [-fn] [-p varname] [id ...] id id. id pid jobspec; , wait . id , wait , $!, . -n, wait id , id , . id id , 127. -p, wait , , varname, . , , , . -n. -f, , wait id, , . id , 127. wait , varname , 128, above. id. Bash-4.0 " " shell compatibility level, shopt (compat31, compat32, compat40, compat41 ). , . , , , . . , (, compat32 , , , bash-3.2 ). , , compat32, , . , , bash, . , [[ bash-4.1, ASCII, compat32 ASCII. . , . Bash-4.3 : BASH_COMPAT. , ( , , 4.2, , compatNN, , 42), . bash-4.4, bash . BASH_COMPAT. Bash-5.0 , shopt. BASH_COMPAT - , , bash-5.0. , . compatNN NN . , bash-5.0, compatNN shopt. bash-4.3 BASH_COMPAT bash-5.1 . compat31 o rhs [[ (=~) . compat32 o < > [[ ; ASCII. compat40 o < > [[ ; ASCII. Bash, bash-4.1, ASCII strcmp(3). bash-4.1 strcoll(3). compat41 o posix time , ( POSIX 267). o posix , word , , : ( POSIX 221). compat42 o , bash-4.2. o posix word , ( POSIX 221). - , . compat43 o , posix ( , ). o (while/until/ ..) , break continue . Bash-4.4 , , . compat44 o , BASH_ARGV BASH_ARGC, , . o , break continue . Bash-5.0 , o , , export readonly, , , posix. compat50 o Bash-5.1 $RANDOM, . 50 , bash-5.0 , RANDOM , bash-5.0. o - , bash, bash-5.1, , , . Bash-5.1 , -l. compat51 o unset @ * - , . o ( ((...)) ) . o , [[, . o , , . o $((...)) . o , , . o test -v, A[@], A - , true, - . Bash-5.2 @ . o ${parameter[:]=value} value , - , (, ). Bash-5.2 , . o , ( shopt ), , (, ), . , (extglob) . , . compat52 o test , , . o -p -P bind, bind , , , , , , . bash rbash -r, restricted. , , . bash, , : o cd. o SHELL, PATH, HISTFILE, ENV BASH_ENV. o , /. o , / .. o -p ., . o , , history. o , , -p hash. o . o BASHOPTS SHELLOPTS . o >, >|, <>, >&, &> >>. o exec . o -f -d enable. o enable . o -p command. o set +r shopt -u restricted_shell. . When a command that is found to be a shell script is executed (see COMMAND EXECUTION above), rbash , . Bash, (Brian Fox) (Chet Ramey) Readline Gnu, (Brian Fox) (Chet Ramey) Gnu, (Brian Fox) (Chet Ramey) (POSIX), 2: , IEEE -- http://pubs.opengroup.org/onlinepubs/9799919799/ http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode sh(1), ksh(1), csh(1) emacs(1), vi(1) readline(3) /bin/bash bash /etc/profile , ~/.bash_profile , ~/.bashrc ~/.bash_logout , ~/.bash_history HISTFILE, , bash ~/.inputrc readline (Brian Fox). bfox@gnu.org (Chet Ramey). Case Western Reserve chet.ramey@case.edu bash, . , bash. ftp://ftp.gnu.org/pub/gnu/bash/ http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz. , , bashbug, . , ! "philosophical" bug-bash@gnu.org Usenet gnu.bash.bug. : bash , short "recipe" bashbug , . , , chet.ramey@case.edu. . bash sh, , - - POSIX . . "a ; b ; c" . , . , . () . () Aleksandr Felda ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. GNU Bash 5.3 07 2025 BASH(1)