BASH(1) General Commands Manual BASH(1) bash - - (Bourne-Again SHell) bash [] [_ | ] Bash is Copyright (C) 1989-2025 by the Free Software Foundation, Inc. Bash . (Bourne shell) . Bash Korn C (ksh csh). POSIX . Bash IEEE POSIX ( IEEE 1003.1). Bash POSIX ( posix mode) . posix bash. Bash POSIX . set -o . bash : -c -c command_string. command_string $0 . $0 . -i -i . -l bash ( ). -r -r ( ). -s -s . . -D $ . C POSIX. -n . [-+]O [shopt_option] shopt_option shopt ( ). shopt_option -O +O. shopt_option bash shopt . +O . -- -- . -- ( ) . - --. Bash . . --debugger . ( extdebug shopt ). --dump-po-strings -D GNU gettext "po" ( - portable object). --dump-strings -D. --help . --init-file file --rcfile file ~/.bashrc ( INVOCATION ). --login -l. --noediting GNU readline . --noprofile ~/.bash_profile ~/.bash_login ~/.profile. bash ( ). --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. --posix posix bash POSIX . --restricted ( ). --verbose -v. --version bash . -c -s ( ). bash $0 . bash . bash . 0. bash PATH . - --login. ( -s) -c ( isatty(3)) -i. bash PS1 i $- . bash . bash . (Tildes) . 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 an interactive login shell exits, or a non-interactive login shell executes the exit builtin command, 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. The --norc option inhibits this behavior. The --rcfile file option causes bash to use file instead of ~/.bashrc. bash BASH_ENV . bash : if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi PATH . 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 inhibits 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. sh bash posix . bash posix --posix POSIX . ENV . . Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the historical and rarely-seen remote shell daemon, usually rshd, or the secure shell daemon sshd. If bash determines it is being run non-interactively in this fashion, it reads and executes commands from ~/.bashrc, if that file exists and is readable. Bash does not read this file if invoked as sh. The --norc option inhibits this behavior, and the --rcfile option makes bash use a different file instead of ~/.bashrc, but neither rshd nor sshd generally invoke the shell with those options or allow them to be specified. ( ) ( ) -p SHELLOPTS BASHOPTS CDPATH GLOBIGNORE . -p . . (blank) (tab). (whitespace) space isspace(3) . (word) . (token). name . (identifier). (metacharacter) . : | & ; ( ) < > space tab newline (control operator) (token) . : || & && ; ;; ;& ;;& ( ) | |& . ( ) case select ( in ) for ( in do ): ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] . . . . 128+n n. (Pipelines) | |&. : [time [-p]] [ ! ] command1 [ [|||&] command2 ... ] command1 command2. command1 ( ). |& command1 command2 2>&1 |. command1. pipefail. pipefail ( ) . ! . . time . -p POSIX (token) "-". TIMEFORMAT TIMEFORMAT . posix time . . TIMEFORMAT . . . lastpipe shopt ( shopt ) . ; & && || ; & <_>. && || ; & . . & . 0. . ; . . AND OR && || . AND OR . AND command1 && command2 command2 command1 (). OR command1 || command2 command2 command1 . AND OR . . . (list) ( ). . . { list; } . . . . ( ) { } . . ((expression)) . 0 1. . 0. [[ expression ]] () (). . [[ ]] . . -f . [[ < > . == != extglob . = ==. nocasematch . 0 (==) (!=) 1 . : . =~ == !=. POSIX ( POSIX regcomp regexec regex(3)). 0 1 . 2. nocasematch . . . . . ^ $ . BASH_REMATCH . 0 BASH_REMATCH . BASH_REMATCH . n BASH_REMATCH n. Bash BASH_REMATCH . : ( expression ) . . ! expression . expression1 && expression2 expression1 expression2 . expression1 || expression2 expression1 expression2 . && || expression2 expression1 . for name [ [ in word ... ] ; ] do list ; done in . name . in word for ( ). . in 0. for (( expr1 ; expr2 ; expr3 )) [;] do list ; done expr1 . expr2 . expr2 expr3. 1. . break continue ( ) . select name [ in word ] ; do list ; done in . in word ( ). select PS3 . select name . select . (EOF) select 1. name . REPLY. break. select . case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac case word pattern . ) . word . pattern . nocasematch . (clause) . case . ;; case case . ;& ;; . ;;& ;; case . . . 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) coproc. & . : coproc [] [_] . ( ). . COPROC. coproc { [_]; } COPROC . . coproc : . . ( ) . [0]. [1]. ( _ ). . . _PID. wait . coproc . . . : _ () - [-] function _ [()] - [-] _. function . function . - ( ). { } . function . - _ . posix _ POSIX $. ( _ ) . . . ( .) interactive_comments shopt ( ) # . . . interactive_comments . interactive_comments . . . . ( ) ! . : . (\) . < >. \< > \< > ( ). . . $ ` \ !. posix ! . $ ` . : $ ` " \ < >. . . ! . !. * @ ( ). $'' . ANSI C. : \a () \b backspace \e \E \f \n \r \t \v \\ backslash \' \" \? \nnn nnn ( ). \xHH HH ( ). \uHHHH (ISO/IEC 10646) HHHH ( ). \UHHHHHHHH (ISO/IEC 10646) HHHHHHHH ( ). \cx -x. . ($"") . gettext LC_MESSAGES TEXTDOMAINDIR TEXTDOMAIN. C POSIX . . noexpand_translation shopt . shopt . . . . . declare ( declare ). export readonly . . . unset ( ). =[] . (tilde) ( ). integer $((...)) ( ). . alias declare typeset export readonly local ( ). posix command . "+=" . declare . "+=" integer . . "+=" ( ) ( "="), ( ) - . . nameref -n declare local ( declare local ) . . ( nameref ) . . declare -n ref=$1 ref . ref $1. for . nameref. . -n unset. unset . ( ). 0. set. . ( ). ( ). $ ($1-$9) $0 ( ). . . . * ($*) . . . IFS. "$*" "$1c$2c..." c IFS. IFS . IFS . @ ($@) . . . . "$@" "$1" "$2" ... . "$@" $@ ( ). # ($#) . ? ($?) . - ($-) set ( -i). $ ($$) . . ! ($!) bg ( ). 0 ($0) . . bash $0 . bash -c $0 . bash . : _ ($_ ) . _ . . . $_ . BASH bash . BASHOPTS . -s shopt ( ). BASHOPTS shopt . bash . . . BASHPID 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) hash. . BASH_CMDS . BASH_COMMAND (trap) . 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 (monotonic clock) . 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] (release). BASH_VERSINFO[1] (version). BASH_VERSINFO[2] (patch level). BASH_VERSINFO[3] . BASH_VERSINFO[4] ( beta). BASH_VERSINFO[5] MACHTYPE. BASH_VERSION bash ( 5.2.37(3)-release). 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 ( time(3)) . EPOCHREALTIME. EPOCHREALTIME . EPOCHSECONDS ( 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 cpu-company-system GNU. . MAPFILE ( Arrays ) mapfile . OLDPWD cd. OPTARG getopts ( ). OPTIND getopts ( ). OSTYPE bash. . PIPESTATUS ( Arrays ) ( ). bash PIPESTATUS ( [[ (( . PPID (PID) . . PWD cd. RANDOM 0 32767. RANDOM () . . RANDOM . READLINE_ARGUMENT readline "bind -x" ( ) . READLINE_LINE readline "bind -x" ( ). READLINE_MARK ( ) readline "bind -x" ( ). . READLINE_POINT readline "bind -x" ( ). REPLY read . SECONDS . SECONDS . . SECONDS . SHELLOPTS . -o set ( ). SHELLOPTS on () set -o. bash . . . SHLVL bash. SRANDOM Each time it is referenced, this variable expands to a 32-bit pseudo-random number. The random number generator is not linear on systems that support /dev/urandom or arc4random(3), so each returned number has no relationship to the numbers preceding it. The random number generator cannot be seeded, so assignments to this variable have no effect. If SRANDOM is unset, it loses its special properties, even if it is subsequently reset. UID (user ID) . . . bash . BASH_COMPAT . . ( 4.2) ( 42) . BASH_COMPAT . BASH_COMPAT . . 4.2 42 shopt compat42 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 inode . ( ) . -mtime ( ). numeric ( "2" "10", ). numeric . nosort bash - . name + - . . HISTCONTROL . ignorespace (space) . ignoredups . ignoreboth ignorespace ignoredups. erasedups . . HISTCONTROL bash HISTIGNORE. HISTCONTROL. . HISTFILE The name of the file in which command history is saved (see HISTORY below). Bash assigns a default value of ~/.bash_history. If HISTFILE is unset or null, the shell does not save the command history when it exits. HISTFILESIZE . . . history . 0 . . HISTSIZE . HISTIGNORE . HISTIGNORE . ( bash "*"). HISTCONTROL. "&" . "&"; . HISTIGNORE. . extglob. HISTIGNORE HISTCONTROL. "&" "ignoredups", "[ ]*" "ignorespace". "ignoreboth". HISTSIZE ( ). 0 . ( ). 500 . HISTTIMEFORMAT strftime(3) history . . . HOME cd. (tilde). HOSTFILE Contains the name of a file in the same format as /etc/hosts that should be read when the shell needs to complete a hostname. The list of possible hostname completions may be changed while the shell is running; the next time hostname completion is attempted after the value is changed, bash adds the contents of the new file to the existing list. If HOSTFILE is set, but has no value, or does not name a readable file, bash attempts to read /etc/hosts to obtain the list of possible hostname completions. When HOSTFILE is unset, bash clears the hostname list. IFS read . . "". IGNOREEOF EOF . EOF bash. 10. EOF . INPUTRC The filename for the readline startup file, overriding the default of ~/.inputrc (see READLINE below). 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?" ":~/shell-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 ( PROMPTING ). . PS0 ( PROMPTING ) . PS1 ( PROMPTING ) . "\s-\v\$ ". PS2 PS1 . "> ". PS3 select ( SHELL GRAMMAR ). PS4 PS1 bash . PS4 . "+ ". SHELL . bash . TIMEFORMAT time. % . . %% % . %[p][l]R . %[p][l]U . %[p][l]S . %P (%U + %S) / %R. p . 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 . . . jobs. exact substring . substring %? ( JOB CONTROL ). ( prefix) %string. histchars ( HISTORY EXPANSION ). "!". "^". . "#", . . . Bash . declare . . ( ARITHMETIC EVALUATION ) . . . 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 EXPANSION values . . . : name=( key1 value1 key2 value2 ...). name=( [key1]=value1 [key2]=value2 ...). . / . declare. name[subscript]=value . name name -1 . "+=" PARAMETERS . ${name[subscript]}. . subscript @ * name . . ${name[*]} IFS ${name[@]} name . ${name[@]} . . * @ ( Special Parameters ). ${#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 . ( mapfile) . . . : . : ( ) . : . . . . . "$@" "${name[@]}" $* ${name[*]} ( PARAMETERS). . . . . . . 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 ( SHELL BUILTIN COMMANDS ) sh. ( "~"), ( ) . . HOME. HOME . . "~+", PWD . "~-", OLDPWD . N "+" "-", dirs . "+" "-", "+". . . Bash : = . PATH MAILPATH CDPATH . Bash ( PARAMETERS) . Bash posix. "$" . . "}" . ${parameter} parameter. parameter parameter . parameter (PARAMETERS) (Arrays). parameter (!) parameter nameref . Bash parameter parameter parameter . . . parameter parameter . ${!prefix*} ${!name[@]} . . word . ( :-) bash . . ${parameter:-word} . parameter word. parameter. ${parameter:=word} . parameter word parameter parameter. . ${parameter:?word} . parameter word ( word ) . . parameter. ${parameter:+word} . parameter word. parameter. ${parameter:offset} ${parameter:offset:length} . length parameter offset. parameter @ * @ * . :length ( ) parameter offset . offset 0. length offset 0. length offset ( ARITHMETIC EVALUATION ). offset parameter. length parameter offset . :-. parameter @ * length offset. offset -1 ( 0 ). length . parameter @ * length ${parameter[offset]}. offset . length . . 1 . offset 0 $0. ${!prefix*} ${!prefix@} . prefix IFS . @ . ${!name[@]} ${!name[*]} . name () name. name 0 name . @ . ${#parameter} . parameter. parameter * @ . parameter * @ . parameter parameter -1 . ${parameter#word} ${parameter##word} . word parameter Pattern Matching . parameter parameter ( "#" ) ( "##" ). parameter @ * . parameter @ * . ${parameter%word} ${parameter%%word} . word parameter Pattern Matching . parameter parameter ( "%" ) ( "%%" ). parameter @ * . parameter @ * . ${parameter/pattern/string} ${parameter//pattern/string} ${parameter/#pattern/string} ${parameter/%pattern/string} . pattern parameter Pattern Matching . 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} . parameter. pattern . Bash parameter pattern . . . "^" pattern "," . ^ , pattern ^^ ,, pattern. pattern ? . parameter @ * . parameter @ * . ${parameter@operator} . 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) () `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 . . <(list) >(list). list . . >(list) list. <(list) list. < > . (FIFOs) /dev/fd . . . . IFS . IFS ( ) IFS. IFS space . IFS <><><_> IFS . IFS (null) null ( ) . IFS . IFS IFS IFS IFS . IFS IFS IFS IFS . IFS . IFS . (null) ("" '') . . . . "-d''" "-d" . -f bash * ? [. ( ) GLOBSORT. nullglob . nullglob . failglob bash . nocaseglob . "." at the start of a name or immediately following a slash must be matched explicitly, unless the shell option dotglob is set. In order to match the filenames . and .., the pattern must begin with "." ( ".?"), even if dotglob is set. If the globskipdots shell option is enabled, the filenames . and .. never match, even if the pattern begins with a ".". "." . . shopt nocaseglob nullglob globskipdots failglob dotglob. The GLOBIGNORE shell variable may be used to restrict the set of file names matching a pattern. If GLOBIGNORE is set, each matching file name that also matches one of the patterns in GLOBIGNORE is removed from the list of matches. If the nocaseglob option is set, the matching against the patterns in GLOBIGNORE is performed without regard to case. The filenames . and .. are always ignored when GLOBIGNORE is set and not null. However, setting GLOBIGNORE to a non-null value has the effect of enabling the dotglob shell option, so all other filenames beginning with a "." . ".", ".*" GLOBIGNORE. dotglob GLOBIGNORE . GLOBIGNORE extglob. GLOBSORT . . NUL . . . : * . globstar * * . / * . ? . [...] . . . [ ! ^ . - . ] . LC_COLLATE LC_ALL . [a-d] [abcd] LC_COLLATE LC_ALL C globasciiranges. [:class:] class POSIX : alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit . word _. [=c=] ( ) c. [.symbol.] symbol. extglob shopt . pattern-list |. : ?(pattern-list) . *(pattern-list) . +(pattern-list) . @(pattern-list) . !(pattern-list) . extglob . extglob . dotglob : dotglob ".", but . and .. must be matched by a pattern or sub-pattern that begins with a dot; when it is disabled, the set does not include any filenames beginning with "." ".". If the globskipdots shell option is enabled, the filenames . and .. never appear in the set. As above, "." . . . \ ' " . . . exec . . . {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 -. ( Duplicating File Descriptors ) . ( 1) ( 2) word. : &>>word >>word 2>&1 ( Duplicating File Descriptors ). "" (Here Documents) delimiter ( ). ( n n) . "" : [n]<<[-]word here-document delimiter word. word delimiter word "". word delimiter word "" : "" \ \ \ $ ` . <<- delimiter. "" . \ : . "" . "" (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. . . alias unalias ( SHELL BUILTIN COMMANDS ). . . . / $ ` = (metacharacters) . . . ls ls -F bash . . alias unalias. . ( FUNCTIONS ) . expand_aliases shopt ( shopt SHELL BUILTIN COMMANDS ). . Bash . . . . . . . alias . . SHELL GRAMMAR . . ( ). . # . 0 . FUNCNAME . : (traps) DEBUG RETURN ( trap SHELL BUILTIN COMMANDS ) trace ( declare ) -o functrace set ( DEBUG RETURN) ERR -o errtrace. local (local variables). . local ( ). . "global" . local declare . "shadow" . : . . . . . . var func1 func1 func2 var func2 var func1 var. unset : unset . ( ) . . unset ( localvar_unset ). FUNCNEST 0 . . return . return return. RETURN . # . -f declare typeset . -F declare typeset ( extdebug ). ( ) -f export. -f unset . (recursive). FUNCNEST . bash . ( let declare (( for [[ Arithmetic Expansion). 0 . C. . . id++ id-- ++id --id - + ! ~ ** * / % + - << >> <= >= < > == != & AND ^ OR (XOR) | OR && AND || OR expr?expr:expr = *= /= %= += -= <<= >>= &= ^= |= expr1 , expr2 . . "x" x . 0 . (integer) declare -i. 0. . C . 0 . 0x 0X . [base#]n base 2 64 n . base# 10. n 9 @ _ . base 36 10 35. . . [[ test [ . test [ . . . . Bash handles several filenames specially when they are used in expressions. If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally with this behavior: If any file argument to one of the primaries is of the form /dev/fd/n, then bash checks file descriptor n. If the file argument to one of the primaries is one of /dev/stdin, /dev/stdout, or /dev/stderr, bash checks file descriptor 0, 1, or 2, respectively. . [[ 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 (effective group id). -L file file . -N file file . -O file file (effective user id). -S . -o _ _ . -o set . -v _ _ ( ). _ @ * . _ @ * . -R _ _ . -z . -n . 1 = 2 string1 = string2 . = test POSIX ( ). 1 != 2 . 1 < 2 1 2 . 1 > 2 1 2 . 1 -ef 2 1 2 (inode). 1 -nt 2 1 ( ) 2 1 2 . 1 -ot 2 1 2 2 1 . 1 OP 2 OP -eq -ne -lt -le -gt -ge. 1 2 . 1 2 . [[ 1 2 ( ). [[ 1 2 0. . 1. ( ) . 2. . . 3. REDIRECTION. 4. = (tilde) . . ( ) . . . . . . . . . . . FUNCTIONS. . . bash PATH . bash (hash table) ( hash SHELL BUILTIN COMMANDS ). Bash PATH . command_not_found_handle. . 127. . 0 . . Bash . ( hash SHELL BUILTIN COMMANDS) . #! . . . : o exec. o cd pushd popd . o umask . o (traps) trap. o set . o . o ( ) set. o shopt. o alias. o $$ PPID. . . o . o . o . o . o . . subshell . . (pipeline) lastpipe . . posix -e . posix bash -e . inherit_errexit posix. If a command is followed by a & and job control is not active, the default standard input for the command is the empty file /dev/null. Otherwise, the invoked command inherits the file descriptors of the calling shell as modified by redirections. . - =. . . . export declare -x unset . . unset export -n export declare -x. PARAMETERS . . . -k ( set ) . bash _ . waitpid . 0 255 125 . . . . . N bash 128+N . 127. 126. . 0 () () . 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 ( JOB CONTROL ). disown ( SHELL BUILTIN COMMANDS ) SIGHUP disown -h. huponexit shopt bash SIGHUP . bash . bash wait wait 128 . bash SIGINT ( ^C) . ^C SIGINT . bash . bash . bash . JOB CONTROL . 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 ) . () () . bash. (pipeline). jobs. jobs . 1. bash ( ) : [1] 25647 1 25647. . Bash . . . . ( ) SIGINT. . . "stty tostop", . SIGTTIN (SIGTTOU) ( "tostop" ) . bash bash . ( ^Z Control-Z) bash. ( ^Y Control-Y) bash. bg fg kill . . SIGSTOP kill. . % (jobspec). n %n. . %ce ce. %?ce ce. bash . %% %+ . % ( ) . %- . . . . %+ %- . ( 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{} strftime(3) . . \e ASCII (033). \h ".". \H . \j . \l ( "ttys0"). \n . \r . \s : $0 ( ). \t 24 HH:MM:SS. \T 12 HH:MM:SS. \@ 12 /. \A 24 HH:MM. \u . \v bash ( 2.00). \V bash + ( 2.00.0) \w PWD ( $PWD) $HOME ( PROMPT_DIRTRIM). \W $PWD $HOME . \! . \# . \$ (UID) 0 # $. \nnn nnn. \\ . \[ . \] . : ( HISTORY ) . promptvars ( shopt SHELL BUILTIN COMMANDS ). . READLINE --noediting . -e read . emacs vi. -o emacs -o vi set ( SHELL BUILTIN COMMANDS ). +o emacs +o vi set. Readline Emacs . C-key C-n Control-N. meta M-key M-x Meta-X. Meta "Alt" "Option". Meta M-x ESC x Escape x . ESC meta. M-C-x ESC Control-x: Escape Control x . Meta (0200). enable-meta-key . meta ESC . Meta ESC meta M-key ( Readline Key Bindings ) force-meta-prefix. Readline . . ( kill-line) . . . . Readline : readline active-region-start-color. enable-active-region . . (). . . . Readline Readline is customized by putting commands in an initialization file (the inputrc file). The name of this file is taken from the value of the INPUTRC shell variable. If that variable is unset, the default is ~/.inputrc. If that file does not exist or cannot be read, readline looks for /etc/inputrc. When a program that uses the readline library starts up, readline reads the initialization file and sets the key bindings and variables found there, before reading any user input. inputrc. . # . $ . . inputrc. readline bash . M-Control-u: universal-argument C-Meta-u: universal-argument inputrc M-C-u readline universal-argument. : DEL ESC ESCAPE LFD NEWLINE RET RETURN RUBOUT ( ) SPACE SPC TAB. readline (macro). . Readline inputrc . . : Meta- Control- . . . 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". GNU Emacs \C- . \M- meta meta force-meta-prefix. \e . \\ . \" " . \' ' . GNU Emacs : \a () \b backspace \d delete \f \n newline \r \t \v \nnn nnn ( ). \xHH HH ( ). . . . " '. Bash readline bind. -o emacs -o vi set ( SHELL BUILTIN COMMANDS ) . Readline Readline . inputrc set variable-name value bind ( SHELL BUILTIN COMMANDS ). readline On Off ( ). . readline "on" ( ) "1" On. Off. bind -V readline ( SHELL BUILTIN COMMANDS ). : active-region-start-color ( enable-active-region ). . . . (standout) terminfo . "\e[01;33m". active-region-end-color "undoes" active-region-start-color "normal" . . . . (standout) 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 ( "#") insert-comment readline. M-# emacs # vi. completion-display-width (-1) . 0 . 0 . -1. completion-ignore-case (Off) On readline . completion-map-case (Off) On completion-ignore-case readline (-) (_) . completion-prefix-display-length (0) () . readline (...) . readline . completion-query-items (100) possible-completions. . readline readline . readline . convert-meta (On) On readline ASCII ( meta). On readline Off . LC_CTYPE . force-meta-prefix . 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 . meta control . \1 \2 . enable-active-region (On) On readline . readline active-region-start-color (standout) . (bracketed-paste) . enable-bracketed-paste (On) On readline . readline . enable-keypad (Off) On readline . . enable-meta-key (On) On readline meta . Meta (0200) Meta ( meta). expand-tilde (Off) On readline (~) . force-meta-prefix (Off) On readline \M- Meta- ( Key Bindings ) \M-C Meta-C ESC C ( meta). force-meta-prefix Off () readline convert-meta : convert-meta On readline Off readline C meta (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. vi vi-command 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 meta. 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 command vi insertion. ( emacs-mode-string). skip-completed-text (Off) On . . readline . vi-cmd-mode-string ((cmd)) show-mode-in-prompt vi . meta control . \e1 \e2 . vi-ins-mode-string ((ins)) show-mode-in-prompt vi . meta control . \e1 \e2 . 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 . . bash: $if Bash # "\C-xq": "\eb\"\ef\"" $endif variable variable readline. = == !=. . . on off. $else $if . $endif $if. $include This directive takes a single filename as an argument and reads commands and key bindings from that file. For example, the following directive would read /etc/inputrc: $include /etc/inputrc Readline ( HISTORY ) . : . . 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. . Readline : readline active-region-start-color. 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 . 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\*" (tilde) . . HISTORY EXPANSION . history-expand-line (M-^) . HISTORY EXPANSION . magic-space . HISTORY EXPANSION . alias-expand-line . ALIASES . 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 ( C-d) stty(1). readline EOF. delete-char (C-d) . tty EOF C-d . Delete . backward-delete-char (Rubout) . (kill ring). forward-backward-delete-char . quoted-insert (C-q, C-v) . C-q . tab-insert (C-v TAB) (tab). self-insert (a, b, A, 1, !, ...) . bracketed-paste-begin "bracketed paste" . 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 . (Killing and Yanking) kill-line (C-k) (Kill) . . backward-kill-line (C-x Rubout) . . unix-line-discard (C-u) (kill-ring). 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 (slash) . delete-horizontal-space (M-\) . kill-region (region) . copy-region-as-kill (kill buffer) (yanked) . 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 . . . complete (TAB) . Bash ( Programmable Completion ) ( $) ( ~) ( @) ( ) . . 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-{) ( Brace Expansion ). 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 ( Meta) . x . prefix-meta (ESC) Meta. ESC f Meta-f. undo (C-_, C-x C-u) . revert-line (M-r) . undo . tilde-expand (M-&) (tilde expansion) . set-mark (C-@, M-) (mark) . . 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-#) comment-begin readline . : 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 . (compspec) . ( ) bash -E complete. -I complete ; |. . bash . bash . bash -D complete . bash . bash Completing. bash . bash actions . . -f -d bash FIGNORE . -G. . Bash FIGNORE GLOBIGNORE. -W. IFS . (metacharacters) IFS. (~) . Word Splitting. . 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 . . (Backslash) . . bash (filter) -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 . HISTSIZE : HISTSIZE ( 500). ( ) HISTIGNORE HISTCONTROL. On startup, bash initializes the history list by reading history entries from the file named by the HISTFILE variable (default ~/.bash_history). That file is referred to as the history file. The history file is truncated, if necessary, to contain no more than the number of history entries specified by the value of the HISTFILESIZE variable. If HISTFILESIZE is unset, or set to null, a non-numeric value, or a numeric value less than zero, the history file is not truncated. . 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) . (modifiers) . (metacharacter) . . ! . . (\) . : = . ( histchars) . !! . . . shopt ( shopt ). histverify readline . readline . readline histreedit readline . -p history . -s history . ( histchars ). . . . . ! = ( extglob shopt. !n n. !-n n. !! . "!-1". !string string. !?string[?] string. ? string . string . ^string1^string2^ . string1 string2. "!!:s^string1^string2^" ( ). !# . . . : . ^ $ * - %. 0 (). . 0 () . . n n. ^ : 1. $ . . % "?string?" . . x-y "-y" "0-y". * . "1-$". * . x* x-$. x- x-$ x* . x 0. !!. ":". . h . t . r .xxx . e . p . q . x q . q x . s/old/new/ new old . /. . 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 . . . [-p ] _ [] source [-p ] _ [] . ( source) filename filename. filename . . -p . path filename . PATH filename. filename . bash posix filename PATH -p. sourcepath shopt . PATH. arguments filename. . -T . (trap) DEBUG DEBUG . . DEBUG . -T DEBUG .. filename (0 ) filename . alias [-p] [[=] ...] -p alias alias name=value . name value. value . name value name. alias name ( =value ) . bg [jobspec ...] jobspec &. jobspec . 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 readline readline readline. readline .inputrc '"\C-x\C-r": re-read-init-file'. readline bind. : -m _ 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. -q readline . -u function readline. -r _ keyseq. -x _[: ]- - keyseq. keyseq - . - readline - . readline . . - 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 : ".". The -P option causes cd to use the physical directory structure by resolving symbolic links while traversing dir and before processing instances of .. in dir (see also the -P option to the set builtin command). The -L option forces cd to follow symbolic links by resolving the link after processing instances of .. in dir. If .. appears in dir, cd processes it by removing the immediately previous pathname component from dir, back to a slash or the beginning of dir, and verifying that the portion of dir it has processed to that point is still a valid directory name after removing the pathname component. If it is not a valid directory name, cd returns a non-zero status. If neither -L nor -P is supplied, cd behaves as if -L had been supplied. -e -P cd . -@ . - $OLDPWD . cd CDPATH - cd . cd PWD OLDPWD . true false . command [-pVv] command [arg ...] command . PATH . -p PATH . -V -v command command. -v command -V . -V -v . 127. command . compgen [-V varname] [option] [word] word 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 . -r . -D "default" . -E "empty" . -I ; | . -D -E -I. -D -E -I name . above under Programmable Completion. . -G -W -X ( -P -S) complete. -o - - (compspec) . - : bashdefault bash compspec . default readline compspec . dirnames compspec . readline compspec ( ). . fullquote readline . noquote readline ( ). nosort readline . nospace readline () . plusdirs compspec . -A : alias . -a. arrayvar . binding Readline. builtin . -b. command . -c. directory . -d. disabled . enabled . export . -e. file readline. -f. . . -g. helptopic help. hostname HOSTFILE. job (Job names) . -j. keyword . -k. running . service . -s. setopt -o set. shopt shopt . signal (Signals). stopped . user . -u. variable . -v. -C command . -F. -F function . ($1) ($2) ($3) . function COMPREPLY. -G _ globpat . -P prefix . -S suffix . -W _ wordlist IFS . (Shell quoting) wordlist IFS. . -X _ filterpat . filterpat . ! filterpat filterpat. true -p -r -D -E -I name name . compopt [-o option] [-DEI] [+o option] [name] name options . 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] [[=] ...] . (names) . -p . -p -f -F. -p name declare . -p declare . -f . -F . extdebug shopt . -F -f. -g declare . declare . -I ( nameref) . . : -a ( above). -A ( above). -f . -i ( ARITHMETIC EVALUATION above) . -l . . -n nameref . . -n . nameref . -r name . . -t trace. DEBUG RETURN . . -u . . -x name . "+" "-" +a +A +r . declare typeset name local -g. =value value. -a -A . 0 "-f foo=bar", ( Arrays above), -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 SIGHUP SIGHUP. id -a -r id . id -a -r disown . 0 id . echo [-neE] [arg ...] args . 0 . -n . -e echo . -E . xpg_echo echo . echo -- . echo : \a () \b backspace \c \e \E \f \n \r \t \v \\ backslash \0nnn nnn ( ). \xHH HH ( ). \uHHHH (ISO/IEC 10646) HHHH ( ). \UHHHHHHHH (ISO/IEC 10646) HHHHHHHH ( ). echo . enable [-a] [-dnps] [-f filename] [name ...] . . -n name names. test PATH "enable -n test". name -p . . -n . -a . -s POSIX . -f 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 ...] args . eval. 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 . (trap) EXIT . export [-fn] [name[=value]] ... export -p [-f] names . -f names . -n . -p export . -p -f . -p . export =value. value . 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 . Otherwise, fc invokes the editor named by ename on a file containing those commands. If ename is not supplied, fc uses the value of the FCEDIT variable, and the value of EDITOR if FCEDIT is not set. If neither variable is set, fc uses vi. When editing is complete, fc reads the file containing the edited commands and echoes and executes them. fc command pat rep. Command first . fc "r=fc"-s(dq" "r cc" "cc" "r" . first last . . cmd fc . fg [jobspec] jobspec . jobspec fg . jobspec . getopts _ [ ...] getopts . _ . . getopts name name OPTIND. OPTIND 1 . getopts OPTARG. OPTIND getopts . getopts . OPTIND name ?. getopts getopts . getopts . _ getopts . getopts . OPTERR 0 getopts _ . getopts ? name OPTARG. getopts OPTARG . getopts name (?) OPTARG . getopts name (:) OPTARG . getopts (true) . (false) . hash [-lr] [-p _] [-dt] [] hash name $PATH. name. -p hash filename . -r . PATH (hashed). -d . -t hash . -t hash . -l . -l hash . -t -d -p ( name) . . -t -p -d. name . help [-dms] [] . pattern help . : -d pattern -m pattern -s pattern pattern ( Pattern Matching ) help pattern. pattern help . help . 0 pattern. history [n] history -c history -d history -d - history -anrw [_] history -p [ ...] history -s [ ...] . * . n n . HISTTIMEFORMAT strftime(3) . history HISTTIMEFORMAT . filename history HISTFILE. filename HISTFILE -a, -n, -r, -w . : -c . . -d offset. offset -1 history -d . -d - start end . start end . -a "new" . bash . -n . bash . -r . -w . -p args . arg . -s args . args. HISTTIMEFORMAT history . . 0 offset -d -p. jobs [-lnprs] [ _ ... ] jobs -x [ ... ] . : -l . -n . -p (PID) . -r . -s . jobspec jobs . 0 jobspec . -x jobs jobspec . 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 ...] ( above). 0 let 1 let 0. local [] [[=] ... | - ] 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] [] fd -u array. MAPFILE array . : -d delim . delim mapfile NUL. -n count . count 0 . -O origin. 0. -s count . -t delim ( ) . -u fd . -C callback quantum . -c quantum. -c callback. -C -c 5000. callback . callback . mapfile array . mapfile . popd [-n] [+n] [-n] . 0 dirs popd "popd +0." popd . : -n (stack) . +n n dirs . : "popd +0" "popd +1" . -n n dirs . : "popd -0" "popd -1" . -n popd cd . cd popd . popd n . popd bash dirs 0. printf [-v ] [] arguments format. -v var . : . 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 (epoch). : -1 -2 . -1. printf . %b %q %T ( ) . %n . %s %c l () . %S %C %ls %lc . C . . . . pushd [-n] [+n] [-n] pushd [-n] [] . 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] [ ...] fd -u above name name . name . . IFS ( above ). (\) . : -a _ aname 0. aname . name . -d delim . delim read NUL. -e read readline ( READLINE above) . Readline ( ) readline. -E read readline ( READLINE above) . Readline ( ) bash . -i readline read text . -n _ read nchars EOF read nchars . -N _ read nchars EOF read. read nchars . IFS ( -r ). -p prompt . -r . . ( - ) . -s . (echo) . -t _ read ( ) . . read . read name 128. 0 read . 0 EOF . -u _ fd . delim read NUL . names read REPLY. read ( 128) ( ) -u. readonly [-aAf] [-p] [[=] ...] " " names . -f name . -a -A . -A . name -p . . -p . readonly =. . 0 names -f name . return [n] (shell function) (sourced file) n . n . return (trap handler) . return DEBUG return. return . (source) n . n 8 . RETURN . return . source. set [-abefhkmnptuvxBCEHPT] [-o -] [--] [-] [ ...] set [+abefhkmnptuvxBCEHPT] [+o -] [--] [-] [ ...] set -o set +o . . posix . . . $1 $2 ... $n. : -a . -b . . -e pipeline ( ) list compound command ( SHELL GRAMMAR) above), . while until if elif && || && || ( pipefail) !. -e . ERR . ( above), . -e -e -e . -e -e . -f . -h . . -k . -m . . ( JOB CONTROL above). . (shell) . -n . . . -o - - : allexport -a. braceexpand -B. emacs emacs. --noediting. read -e. errexit -e. errtrace -E. functrace -T. hashall -h. histexpand -H. history above HISTORY. . 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 . SEE ALSO below posix bash. privileged -p. verbose -v. vi vi. read -e. xtrace -x. -o option-name set . +o option-name set set . -p . $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 (trap) ERR . ERR . -H !. . -P cd . . bash . -T DEBUG RETURN . DEBUG RETURN . -- . args -. - arg . -x -v. arg . . + - . . $-. . shift [n] n+1 ... $1 .... $# $#-n+1 . n $#. n 0 . n 1. n $# . n $# 0. shopt [-pqsu] [-o] [- ...] . -o -o set . -p optnames . -p . : -s () optname. -u ( ) optname. -q ( ) optname . optname -q optnames . -o optname -o set. -s -u optname shopt . shopt ( ) . optnames . optname . shopt : array_expand_once . assoc_expand_once array_expand_once. autocd cd. . bash_source_fullpath BASH_SOURCE ( Shell Variables ). cdable_vars cd . cdspell cd . . cd . . checkhash bash . bash . checkjobs bash . bash ( JOB CONTROL above). . checkwinsize bash ( ) LINES COLUMNS . . cmdhist bash . . above HISTORY. compat31 compat32 compat40 compat41 compat42 compat43 compat44 ( SHELL COMPATIBILITY MODE below). complete_fullquote bash (metacharacters) . bash . . bash . bash 4.2. direxpand bash . readline. bash . dirspell bash . dotglob bash "." in the results of pathname expansion. The filenames . and .. must always be matched explicitly, even if dotglob is set. execfail exec. exec. expand_aliases above ALIASES. . extdebug --debugger. : 1. -F declare . 2. DEBUG . 3. DEBUG 2 ( . source) return. 4. BASH_ARGC BASH_ARGV above). 5. : ( ) DEBUG RETURN. 6. : ( command ) ERR. extglob above . extquote $'string' $"string" ${parameter} . . failglob . force_fignore FIGNORE . Shell Variables above FIGNORE. . globasciiranges ( Pattern Matching above) C . b A B ASCII . globskipdots If set, pathname expansion will never match the filenames . and .., even if the pattern begins with a ".". . globstar ** . / . gnu_errfmt GNU . histappend HISTFILE . histreedit readline . histverify readline . readline . hostcomplete readline bash @ ( Completing READLINE above). . huponexit bash SIGHUP . inherit_errexit errexit . posix. interactive_comments # ( 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 ( Pathname Expansion above). nocasematch bash case [[ . noexpand_translation bash $"..." . . nullglob ( Pathname Expansion above) . patsub_replacement bash & Parameter Expansion above. . progcomp ( Programmable Completion above). . progcomp_alias bash . bash . promptvars PROMPTING above. . restricted_shell ( below). . . shift_verbose shift . _ . (source) PATH -p. . varredir_close {varname} ( REDIRECTION above) . xpg_echo echo . posix echo . suspend [-f] SIGCONT. -f . 0 -f. test expr [ ] 0 () 1 () expr. . above . test -- . . . test . ! expr expr . ( expr ) expr. . expr1 -a expr2 expr1 expr2 . expr1 -o expr2 expr1 expr2 . test [ . 0 arguments . (not null). ! . above . . 3 . above . -a -o . ! . ( ) . . 4 . ! . ( ) . . 5 . posix [[ < > . posix test [ ASCII. 4 (primaries). POSIX -a -o . . -a -o && || . times . 0. trap [-lpP] [[] sigspec ...] sigspec. ( sigspec ) - sigspec . (null string) 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 ( SHELL GRAMMAR) above). extdebug ( shopt) above) DEBUG. sigspec RETURN action . source. sigspec ERR action ( ) . ERR while until if && || && || ( pipefail) !. errexit (-e). . . . sigspec trap . true 0. type [-aftpP] name [name ...] name . -t type : alias keyword function builtin file . type . -p type $PATH "type -t name" file. -P PATH name "type -t name" file. name -p -P PATH. -a type name. (-p -P) . type (hashed) -a -p PATH name. -f command. type (true) (false) . ulimit [-HS] -a ulimit [-HS] [-bcdefiklmnpqrstuvxPRT []] . -H -S . . -H -S ulimit . limit hard soft unlimited . limit ulimit -H. . : -a . -b . -c . -d . -e ( "nice"). -f . -i . -k kqueues . -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 chmod(1). mode umask . -S mode . -p mode . mode . unalias [-a] [ ...] name . -a . name . unset [-fv] [-n] [ ...] . -v . -f . -n nameref . -n -f. . . . . BASH_ALIASES BASH_ARGV0 BASH_CMDS BASH_COMMAND BASH_SUBSHELL BASHPID COMP_WORDBREAKS DIRSTACK EPOCHREALTIME EPOCHSECONDS FUNCNAME GROUPS HISTCMD LINENO RANDOM SECONDS SRANDOM . '' . wait [-fn] [-p varname] [id ...] id id. id pid jobspec wait . ids wait $! . -n wait . 127. -p wait varname . . -n. -f wait id . ids 127. wait varname 128 SIGNALS above. id. Bash-4.0 shopt (compat31 compat32 compat40 compat41 ). -- . . . ( compat32 bash-3.2 ). compat32 . bash . (locale) [[ 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 shopt compatNN. bash-4.3 BASH_COMPAT bash-5.1 . compat31 o [[ (=~) . 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 5.1 . Bash-5.1 -l. compat51 o unset @ * . o ( ((...)) ) for . o [[ . o . o $((...)) . o . o test -v A[@] A . Bash-5.2 @. o ${parameter[:]=value} value ( ). Bash-5.2 . o ( shopt ) extglob ( ). extglob . extglob . compat52 o test . o -p -P bind bind . bash rbash -r . . bash : o cd. o SHELL PATH HISTFILE ENV BASH_ENV. o /. o / .. o -p . . o history. o (slash) -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 Gnu Readline Gnu History (POSIX) 2: IEEE -- http://pubs.opengroup.org/onlinepubs/9799919799/ http://tiswww.case.edu/~chet/bash/POSIX -- posix 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 bfox@gnu.org 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 "recipe" bashbug . chet.ramey@case.edu. . bash sh POSIX . . "a ; b ; c" . . . ( ) . 3 . . : . GNU Bash 5.3 7 2025 BASH(1)