BASH



COPYRIGHT
























READLINE










bash - GNU Bourne-Again SHell

bash [options] [file]

COPYRIGHT

Bash is Copyright 1989-2001 by the Free Software Foundation, Inc.

bash - sh- , , . bash Korn C (ksh csh).
bash IEEE POSIX (IEEE POSIX Shell and Tools specification) (IEEE Working Group 1003.2).

, set, bash :
-c
-c, . , , $0.
-r -r, (. " ").
-i -i, .
-s -s , . .
-D $ . , , (locale) C POSIX. -n; .
-- (--) . -- . - --.
bash . , , .
--dump-po-strings
-D, GNU gettext po (portable object - ).
--dump-strings
-D.
--help
.
--init-file
--rcfile
~/.bashrc, (. "" ).
--login
bash , (. "" ).
--noediting
GNU readline .
--noprofile
/etc/profile, ~/.bash_profile, ~/.bash_login ~/.profile. , bash (. "" ).
--norc
~/.bashrc, . , sh.
--posix
bash , POSIX 1003.2, ( posix).
--restricted
(. " " ).
--rpm-requires
, . -n , . Backticks, [] eval , .
--verbose
-v.
--version
bash .

-c -s, , . bash , $0 , . bash , . bash , . , - 0.

(login shell) - , (-) --login
, - -c, ( isatty(3)), -i. PS1 ($-) i, bash , .
, bash . , , bash . (~) , " " "".
bash , --login, /etc/profile, . , ~/.bash_profile, ~/.bash_login ~/.profile, , . --noprofile , .
bash ~/.bash_logout, .
, , bash ~/.bashrc, . --norc. --rcfile bash ~/.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. , bash rshd, ~/.bashrc, . , , bash sh. --norc, --rcfile , rshd .
(), (), -p, , , SHELLOPTS, , , . -p, , .

.
.
, . (token).
, - , . .
, , . :
| & ; ( ) < >
, . :
|| & && ; ;; ( ) | <_>

, . , (. " " ), case for:
! case do done elif else esac fi for function if in select then until while { } time [[ ]]

- , , , . , . .
, 128+n, n.
- , |. :
[time [-p]] [ ! ] 1 [ | 2 ... ]
1 2. , , (. "" ).
!, . , . , , .
time, , , . -p POSIX. TIMEFORMAT ; . TIMEFORMAT " " .
(.. ).
- , ;, &, && ||, ;, & <_>.
&& || , , ; &, .
&, . , - 0. , ; ; . .
&& || , , - -. -
1 && 2
2 , 1 .
-
1 || 2
2 , 1 . - - , .
:
()
. , , . .
{ ; }
. . . .
(())
, " ". , 0; - 1. let "".
[[ ]]
0 1 . , " ". [[ ]] ; , , , , .
== != , " ". 0, , 1 . ( ), .
, :
( )
. .
!
, .
1 && 2
, : 1 2.
1 || 2
, 1 2.
&& || 2, 1 .
for [ in _ ] ; do ; done
_ in, . , . _ in , for (. "" ). . _ in , 0.
for (( 1 ; 2 ; 3 )) ; do ; done
1 , " ". 2 , . 2 3. - , . 1, - .
select [ in _ ] ; do ; done
_ in, . , , , . in , (. "" ). PS3 . , , . , _ . (EOF), . . REPLY. , break return. select , 0, .
case in [ [(] 1 [ | 2 ] ... ) ;; ] ... esac
case , , (. " "). , . . 0, . , .
if ; then ; [ elif ; then ; ] ... [ else ; ] fi
if. - 0, then. , elif, - 0, then . elif 0, else, . 0, .
while 1; do 2; done
until 1; do 2; done
while 2 do, 1 0. until while, - : 2 do , 1 . while until 2 0, .
[ function ] () { ; }
. { }. , . , . (. "" .)

interactive_comments shopt (. " " ), , #, . interactive_comments . interactive_comments .

(quoting) . , , .
, "", , .
, ! , .
: (escape character), .
" " (\) . ( ) . \<_> , (.. , , ).
. () , .
, $, ` \. $ ` . , : $, `, ", \ <_>. , .
* @ - (. "" ).
$'' . , ANSI C. , , :
a
()
b
e
f
n
r
t
v
\
'
\nnn
ASCII nnn ( )
xnnn
ASCII nnn ( )
, .
, ($), (locale). - C POSIX, . , .

() - , . , , " ". , - , .
, . . , , unset (. " " ).
=[]
, . , , , (. "" ). (integer) (. declare " " ), , $((...)) (. " " ). , "$@", " ". .
( ) - , , 0. , . set. . (. "" ).
, , "".
. - .
*
, . , , IFS. , "$*" "$1c$2c...", c - IFS. IFS , . IFS , , .
@
, . , . , "$@" "$1" "$2" ... , "$@" $@ (.. ).
#
.
?
(foreground) .
-
, , set (, , -i).
$
. , (), , .
!
, () .
0
. . bash , $0 . bash -c, $0 , , . , , bash, .
_
, . , , . , . , .
:
PPID
. .
PWD
, cd.
OLDPWD
, cd.
REPLY
, read, .
UID
- . .
EUID
- . .
GROUPS
-, , . . GROUPS unset, , .
BASH
, bash.
BASH_VERSION
, bash.
BASH_VERSINFO
, bash. :
BASH_VERSINFO[0]
().
BASH_VERSINFO[1]
().
BASH_VERSINFO[2]
(patch-level).
BASH_VERSINFO[3]
.
BASH_VERSINFO[4]
(, beta1).
BASH_VERSINFO[5]
MACHTYPE.
SHLVL
1 bash.
RANDOM
0 32767. RANDOM. RANDOM unset, , .
SECONDS
, . SECONDS , , , . SECONDS unset, , .
LINENO
, ( 1) . , . LINENO unset, , .
HISTCMD
( ). HISTCMD unset, , .
FUNCNAME
. . FUNCNAME . FUNCNAME unset, , .
DIRSTACK
- (. "" ), . , dirs. , , pushd popd. . DIRSTACK unset, , .
PIPESTATUS
- (. "" ), (foreground) ( ).
OPTARG
-, getopts (. " " ).
OPTIND
, getopts (. " " ).
HOSTNAME
.
HOSTTYPE
, , bash. .
OSTYPE
, , bash. .
MACHTYPE
, , bash, GNU --. .
SHELLOPTS
. - -o set (. " " ). , SHELLOPTS, set -o. bash, . .
COMP_WORDS
- (. "" ), . , (. " ")
COMP_CWORD
COMP_WORDS, . , (. " ")
COMP_LINE
. , (. " ")
COMP_POINT
. , ${#COMP_LINE}. , (. " ")
. bash ; .
IFS
(Internal Field Separator), , read. - "<><>< >".
PATH
. , (. " " ). , bash. :
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
HOME
; cd. .
CDPATH
cd. , , cd. - ".:~:/usr".
BASH_ENV
bash , , , ~/.bashrc. BASH_ENV , . PATH .
MAIL
MAILPATH, bash .
MAILCHECK
( ) bash. - 60 . , bash . , .
MAILPATH
, . , , (?). $_ . :
MAILPATH='/var/mail/bfox?" ":~/shell-mail?" $_ !"'
bash , (, /var/mail/$USER).
PS1
(. " " ) . :
"s-v$ ".
PS2
, PS1, . : "> ".
PS3
select (. " " ).
PS4
, PS1, , bash . PS4 , . : "+ ".
TIMEFORMAT
, , time. % , . ( ):
%%
%.
%[p][l]R
, .
%[p][l]U
.
%[p][l]S
.
%P
, (%U + %S) / %R
p - , , ( ) . 0 . - ; p 3 3.
l , , MMmSS.FFs. p , .
, bash , $'nrealt%3lRnusert%3lUnsys%3lS'. , . .
HISTSIZE
, (. " " ). - 500.
HISTFILE
, (. " " ). - ~/.bash_history. , .
HISTFILESIZE
, . , , , , , . - 500. .
OPTERR
1, bash , getopts (. " " ). OPTERR 1 .
LANG
(locale) , , LC_.
LC_ALL
LANG LC_, (locale).
LC_COLLATE
, , , .
LC_CTYPE
.
LC_MESSAGES
, , $.
LC_NUMERIC
.
LINES
select . SIGWINCH.
COLUMNS
select . SIGWINCH.
PROMPT_COMMAND
, .
IGNOREEOF
(EOF) . , EOF, , bash . , , 10. , EOF .
TMOUT
, . bash , .
FCEDIT
fc.
FIGNORE
, (. "READLINE" ). , FIGNORE , . - ".o:~".
GLOBIGNORE
, , . , , GLOBIGNORE, , .
INPUTRC
readline, ~/.inputrc (. "READLINE" ).
HISTCONTROL
ignorespace, , , . ignoredups, , , . ignoreboth . - , , , , , HISTIGNORE. , HISTIGNORE. , HISTCONTROL.
HISTIGNORE
, . ('*' ). , HISTCONTROL. , '&' . '&' . . HISTIGNORE.
histchars
, (. " " ). - , . '!'. - , , , . '^'. - . , . '#' . .
HOSTFILE
, /etc/hosts, . ; bash . HOSTFILE , , bash /etc/hosts . HOSTFILE unset, .
auto_resume
. , . ; , . , , - , . exact, ; substring, . %? (. " " ). , ; %.
COMPREPLY
-, bash , (. " ").
bash . ; declare . . , .
[]=. , . declare -a (. " " ). declare -a [] ; . declare readonly. .
=(1 ... N), []=. . , ; , , , . . declare. []=.
${[]}. , . @ *, . -, . , ${[*]} , , IFS, ${[@]} . , ${[@]} . * @ (. " " ). ${#[]} ${[]}. * @, . - .
unset. unset [] . unset , - , unset [], - * @, .
declare, local readonly -a . read -a , . set declare , .

. : , (~), , , , , .
, , , , .
, , , .
, ; . - "$@" "${[@]}", (. "").
- . , . , , - . , , ( ) .
. ; . , a{d,c,b}e "ade ace abe".
, , . - . bash .
, , . . { , . , ${ .
, :
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}, . file1 file2 bash. sh, bash +B +B set (. " " ).
(~), ( , ) -. - , (login name). , HOME. HOME , , . - , .
- '~+', PWD. - '~-', OLDPWD, . - N, '+' '-', - , dirs - . '+' '-', '+'.
, .
- : =. . , PATH, MAILPATH CDPATH, .
'$' , . , , .
, '}', , , .
${}
(). , , .
- , . bash , , , . . ${!*}
, , . , bash , ; , , .
${:-}
. , . .
${:=}
. , . . .
${:?}
. , ( , ) , , . , .
${:+}
. , , , .
${:}
${::}
. , . , . (. " " ). . - , . - @, , , , . - @ *, , , ${[]}. , , , 1.
${!*}
, . IFS.
${#}
. - * @, . - * @, .
${#}
${##}
, . , , ( "#") ( "##") , . - @ *, . - @ *, .
${%}
${%%}
, . , , ( "%") ( "%%") . - @ *, . - @ *, .
${//}
${///}
. , , . , . , . #, , . %, . - , / . - @ *, , . - @ *, .
, , . :
$()
``
bash , . , . $(cat file) , : $(< file).
, $, ` \. , , . $() - .
. .
, .
. :
$(())
, , . , , . .
, " ". , bash .
(FIFO) /dev/fd . : <() >(). , FIFO- /dev/fd. . >() , . <() , .
, , .
, , , .
IFS . IFS - <><><_>, .. , IFS . IFS , , ( ) , IFS ( IFS). IFS, , IFS, . IFS . IFS , .
("" '') . , , , . , , , , .
: , .
, -f, bash *, ? [. , , . nullglob , . nullglob , . nocaseglob, . , "." , dotglob. . "." . nocaseglob, nullglob dotglob . shopt " "
GLOBIGNORE , . GLOBIGNORE , , , GLOBIGNORE, . "." ".." , GLOBIGNORE. GLOBIGNORE dotglob, , ".", . - , ".", - ".*" GLOBIGNORE. dotglob , GLOBIGNORE .
, , , . NUL . .
:
*
, , .
?
.
[...]
. , , ; , , , . [ ! ^, , . LC_COLLATE, . (-) . (]), .
[::], - , POSIX.2:
alnum alpha ascii blank cntrl digit graph lower print punct space upper xdigit
, .
[=c=], (collation weight), , c.
[..] .
shopt extglob, . _ - , (|). :
?(_)
.
*(_)
.
+(_)
( ).
@(_)
.
!(_)
, .
\, ' ", , .

, . . , . , .
- <, ( 0). >, ( 1).
, , , , , , , , . , bash .
: . ,
ls > dirlist 2>&1
dirlist ,
ls 2>&1 > dirlist
dirlist , , dirlist.
bash :
/dev/fd/fd
fd - , fd.
/dev/stdin
0.
/dev/stdout
1.
/dev/stderr
2.
/dev/tcp/host/port
host - IP-, port - ( ), bash TCP- .
/dev/udp/host/port
host - IP-, port - ( ), bash / UDP-.
.
, , n, ( 0), n .
:
[n]<
, , n, ( 1), n . , ; - .
:
[n]>
> set noclobber, , . >|, - > noclobber set , , .
, , n, ( 1), n . , .
:
[n]>>
bash ( 1), ( 2) , .
:
&>
>&
. :
> 2>&1
(Here Documents)
, , ( ). .
:
<<[-]
         

, , . , , . , , . <_> , \ \, $ `.
<<-, , , . .
[n]<&
. , n . , , , . -, n . n , ( 0).
[n]>&
. n , ( 1). , , . , n , , .
[n]<>
, , n 0, n . , .

. , alias unalias (. " " ). , , . , . , . - =. , , . , ls ls -F, .. bash . - , , , .
alias, unalias.
. , (. "" ).
, , shopt expand_aliases (. shopt , " ").
. bash , . , . , , , . , , . . , , . , , , , . , alias .
.

, " ", . ; ( ). ( ). # , . 0 . FUNCNAME . , DEBUG (. trap " " ) .
local. .
return, . , #, .
-f declare typeset. -F declare typeset . , -f export.
. .

(. let " " ). , 0 . , , . . .
id++ id--
- -
++id --id
- -
- +
! ~
**
* / %
, ,
+ -
,
<< >>
<= >= < >
== !=
&
^
|
&&
||
1?2:3
= *= /= %= += -= <<= >>= &= ^= |=
1 , 2
; . . , integer .
0 . 0x 0X . [#]n, - 2 64, , n - . , 10. , 9, , , _ @, . 36, 10 35.
. , .

[[ test [ . . /dev/fd/n, n. /dev/stdin, /dev/stdout /dev/stderr 0, 1 2, .
-a
, .
-b
, .
-c
, .
-d
, .
-e
, .
-f
, .
-g
, SGID.
-h
, .
-k
, sticky-.
-p
, (FIFO).
-r
, .
-s
, .
-t fd
, fd .
-u
, SUID.
-w
, .
-x
, .
-O
, EUID.
-G
, EGID.
-L
, .
-S
, .
-N
, .
1 -nt 2
, 1 , 2 ( ).
1 -ot 2
, 1 , 2.
1 -ef 2
, 1 2 i-.
-o
, . . -o set.
-z
, (.. ).
-n
, .
1 == 2
, . == =.
1 != 2
, .
1 < 2
, 1 2.
1 > 2
, 1 2.
arg1 OP arg2
OP : -eq, -ne, -lt, -le, -gt -ge. , arg1 , , , , , arg2, . arg1 arg2 .

, , , .
1.
, (, ) .
2.
. - , , - .
3.
, "".
4.
= , , , , .
, . , . , .
, , . .
, , . , . , , . , .

, , .
, . , "". , . , .
, bash PATH . bash - (. hash " " ). PATH -. , 127.
, . 0 , , , .
, , , , , . . , , , (. hash " "), .
#!, . , . , , , .

, :
-
, , , , exec;
-
, cd, pushd popd, ;
-
, umask ;
-
, trap;
-
, ;
-
, ;
-
, ( , ) set;
-
, shopt;
-
, alias;
-
, , , $$ $PPID.
, , , . , :
-
, ;
-
;
-
;
-
, , , ;
-
, , , .
, , .
, , , , , . , , . .

, . =.
. , . . export declare -x . , , , , . , , , , , unset, , export declare -x.
, "". .
-k, (. set ), , , .
bash , _ .

, , 0, . 0 . . N, bash 128+N.
, 127. , , 126.
, , .
0 () , (), . 2.
bash , . . . exit .

bash , , SIGTERM ( kill $0 ), SIGINT (, wait ). , bash SIGQUIT. , bash SIGTTIN, SIGTTOU SIGTSTP.
, bash, , . , SIGINT SIGQUIT. , , SIGTTIN, SIGTTOU SIGTSTP, .
SIGHUP. SIGHUP , , . SIGCONT, SIGHUP. , disown (. " " ) SIGHUP disown -h.
shopt huponexit, bash SIGHUP .
bash , , , , , . bash wait, , , wait 128 .

- () () . , bash.
. , jobs. ( ) bash :
[1] 25647
, 1, , - 25647. . bash .
. (, ) , , SIGINT. ( ). - , ; . . , ( ) SIGTTIN (SIGTTOU), , , .
, bash, , bash . ( ^Z, Control-Z) , bash. ( ^Y, Control-Y) , bash. , bg , fg - kill . ^Z , .
. % . n %n. , , , . , %ce ce. , bash . %?ce, , , ce. , bash . %% %+ - , . %-. , , ( , jobs), +, - -.
: %1 - "fg %1", 1 . , "%1 &" 1 "bg %1".
. bash , . set -b, bash .
bash, . jobs . , .

bash PS1, , PS2, . bash :
a
ASCII- "" (07)
d
"_ " (.., "Tue May 26")
e
ASCII- (033)
h
H
j
l
n
r
s
- $0 ( )
t
24- ::
T
12- ::
@
12- am/pm (/)
u
v
bash (, 2.00)
V
bash, + (, 2.00.0)
w
W
!
#
$
- 0, #, - $
\nnn
, nnn
\
[
,
]
e
: , , (. " " ), , . , , , , promptvars (. shopt " " ).

READLINE

, , --noediting. , emacs. vi. +o emacs +o vi set (. " " ).
readline
emacs. C-, C-n Control-N. , M-, M-x Meta-X. ( , Meta, M-x ESC x, .. Escape x. , ESC meta. M-C-x ESC Control-x, .. Escape, , Control, x.)
readline , . , , . , (, kill-line) . , , .
, (). . , . , , .
readline
readline ( inputrc). INPUTRC. , , ~/.inputrc. , readline, . readline . . , #, . , $, . .
inputrc. , , .
,
M-Control-u: universal-argument
C-Meta-u: universal-argument
M-C-u universal-argument readline.
: RUBOUT, DEL, ESC, LFD, NEWLINE, RET, RETURN, SPC, SPACE TAB.
, readline , (.. ).
readline
inputrc . , . : , , Meta- Control-, .
_:_ , _ . :
Control-u: universal-argument
Meta-Rubout: backward-kill-word
Control-o: "> output"
C-u universal-argument, M-DEL - backward-kill-word, C-o - , (.. "> output" ).
, "_":_ , _ , . GNU Emacs, , .
"C-u": universal-argument
"C-xC-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-
Control
M-
Meta
e
\
"
"
'
'
GNU Emacs, , :
a
(bell)
b
(backspace)
d
(delete)
f
(form feed)
n
r
t
v
\nnn
, ASCII- nnn ( )
xnnn
, ASCII- nnn ( )
, . . , . , , " '.
bash readline bind. -o set (. " " ).
readline
readline , . inputrc
set _
, readline On Off. :
bell-style (audible)
, , readline ( ) . none, readline . visible, readline , . audible, readline .
comment-begin ('#')
, insert-comment readline. M-# emacs # vi.
completion-ignore-case (Off)
On, readline .
completion-query-items (100)
, , possible-completions. . , , ; .
convert-meta (On)
On, readline ASCII (, -).
disable-completion (Off)
On, readline . , self-insert.
editing-mode (emacs)
, readline - emacs vi. editing-mode emacs vi.
enable-keypad (Off)
On, readline . .
expand-tilde (Off)
On, .
horizontal-scroll-mode (Off)
On, readline , . .. .
input-meta (Off)
On, readline (.. ), , . meta-flag - .
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 .
mark-directories (On)
On, .
mark-modified-lines (Off)
On, , , (*).
output-meta (Off)
On, readline , , .
print-completions-horizontally (Off)
On, readline , , , .
show-all-if-ambiguous (Off)
. On, , , , .
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= , , . = -. , , sun sun, sun-cmd.
. , readline, , . , . , , bash:
$if Bash
#       
"C-xq": "eb"ef""
$endif
$endif
, , $if.
$else
$if , .
$include
. , /etc/inputrc:
$include  /etc/inputrc
readline (. " " ) , . : .
, . , readline , . , . isearch-terminators . , Escape Control-J. Control-G . , , , .
, Control-S Control-R, . , , . , readline, . , Enter .
. .
readline
, . , , . "" , "" - , set-mark. "".
beginning-of-line (C-a)
.
end-of-line (C-e)
.
forward-char (C-f)
.
backward-char (C-b)
.
forward-word (M-f)
. - ( ).
backward-word (M-b)
. - ( ).
clear-screen (C-l)
, . , .
redraw-current-line
.
accept-line (Newline, Return)
, . - , HISTCONTROL. , .
previous-history (C-p)
, .
next-history (C-n)
, .
beginning-of-history (M-<)
.
end-of-history (M->)
, .. .
reverse-search-history (C-r)
, , , . .
forward-search-history (C-s)
, , , . .
non-incremental-reverse-search-history (M-p)
, .
non-incremental-forward-search-history (M-n)
, .
history-search-forward
. .
history-search-backward
. .
yank-nth-arg (M-C-y)
( ) . n, n- ( 0). - , n- .
yank-last-arg (M-., M-_)
( ). , , yank-nth-arg. yank-last-arg , .
shell-expand-line (M-C-e)
. , . . " ".
history-expand-line (M-^)
. . " ".
magic-space
. . " ".
alias-expand-line
. . "".
history-and-alias-expand-line
.
insert-last-argument (M-., M-_)
yank-last-arg.
operate-and-get-next (C-o)
. .
delete-char (C-d)
. - , delete-char, EOF.
backward-delete-char (Rubout)
. (kill ring).
forward-backward-delete-char
, , - . .
quoted-insert (C-q, C-v)
. , , C-q.
tab-insert (C-v TAB)
.
self-insert (a, b, A, 1, !, ...)
.
transpose-chars (C-t)
. . - , . .
transpose-words (M-t)
, ( ) . .
upcase-word (M-u)
( ). , , .
downcase-word (M-l)
( ). , , .
capitalize-word (M-c)
. , , .
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.
unix-word-rubout (C-w)
, . .
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 , - . , , , count . count 1, , - .
complete (TAB)
, . bash , ( $), ( ~), ( @), ( ). , .
possible-completions (M-?)
.
insert-completions (M-*)
, possible-completions.
menu-complete
complete, . menu-complete . . n n ; . TAB, .
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)
, .
complete-into-braces (M-{)
, (. " " ).
start-kbd-macro (C-x ()
.
end-kbd-macro (C-x ))
.
call-last-kbd-macro (C-x e)
, , .
re-read-init-file (C-x C-r)
inputrc .
abort (C-g)
( bell-style).
do-uppercase-version (M-a, M-b, M-x, ...)
x, Meta, , , .
prefix-meta (ESC)
Meta. ESC f Meta-f.
undo (C-_, C-x C-u)
, .
revert-line (M-r)
. undo .
tilde-expand (M-&)
.
set-mark (C-@, M-<space>)
. , .
exchange-point-and-mark (C-x C-x)
. , .
character-search (C-])
. .
character-search-backward (M-C-])
. .
insert-comment (M-#)
comment-begin readline , , Enter. comment-begin , .
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, , , . , , inputrc.
display-shell-version (C-x C-v)
bash.
, complete (. " " ) , .
. , . - , , . , , , .
, . , bash, "".
, . , . -f -d, FIGNORE.
, -G. , , . GLOBIGNORE , FIGNORE.
, -W. IFS, . , , , , , "". . , .
, -F -C. , COMP_LINE COMP_POINT , " ". , COMP_WORDS COMP_CWORD . , , , , - , . . .
, -F. , compgen, . - COMPREPLY.
, -C. , . . .
, , , -X. , . & . & , , & . , , . !, : , .
, -P -S. readline .
, complete -o dirnames, .
, , , , . bash , readline . complete -o default, , , readline.

-o history set, - . HISTSIZE . HISTSIZE ( - 500) . (. "" ), , HISTIGNORE HISTCONTROL.
, HISTFILE ( - ~/.bash_history). HISTFILE , HISTFILESIZE . HISTSIZE HISTFILE. histappend (. shopt " " ), , . HISTFILE , . HISTFILESIZE . HISTFILESIZE .
fc (. " " ) . history , . .
, . HISTCONTROL HISTIGNORE . cmdhist, , , . lithist . shopt " ".

bash , csh. . +H set (. " " ). .
, , .
, . . , . . , , - , , , - . . , , , , . . - !. (\) .
shopt. histverify (. shopt) readline, . , readline . readline histreedit, readline . -p history . -s history , .
, (. histchars " ").
(event designator) - .
!
, , , = (.
!n
n.
!-n
n.
!!
. "!-1".
!
, .
!?[?]
, . ? , .
^1^2^
. , 1 2. "!!:s/1/2/" (. "" ).
!#
.
(word designators) . (:) . , ^, $, *, - %. , 0. .
0 (zero)
. - .
n
n- .
^
, .. 1.
$
.
%
, '??'.
x-y
; '-y' - '0-y'.
*
, . '1-$'. * - .
x*
x-$.
x-
x-$, x*, .
, .
, - ':'.
h
, .
t
, .
r
.xxx, .
e
, .
p
, .
q
, .
x
, q, .
s/old/new/
new old . / . , . old new . new &, old. &. old - , , , , !?[?].
&
.
g
. ':s' (, ':gs/old/new/') ':&'. ':s', (/) , , .

, , , (-), (--) .
: []
; , . .
. []
source []
. , , PATH. . , PATH, bash posix, . sourcepath shopt, PATH . , . . ( 0, ), 1, .
alias [-p] [[=] ...]
alias -p "alias =" . , , , . , . . alias , , .
bg []
, &. , . "bg " 0, , , .
bind [-m keymap] [-lpsvPSV]
bind [-m keymap] [-q ] [-u ] [-r keyseq]
bind [-m keymap] -f
bind [-m keymap] -x keyseq:
bind [-m keymap] keyseq:
readline readline. , .inputrc, ; .. '"C-xC-r": re-read-init-file'. , , :
-m keymap
keymap . : emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-command vi-insert. vi vi-command; emacs emacs-standard.
-l
readline.
-p
readline , .
-P
readline.
-v
readline , .
-V
readline.
-s
readline, , , .
-S
readline, ,
-f
.
-q
, .
-u
.
-r keyseq
keyseq.
-x keyseq:
keyseq.
0, .
break [n]
for, while, until select. n , n . n 1. n , . 0, .
builtin _ []
, . , , . cd. , 1.
cd [-LP] []
. HOME. CDPATH , . CDPATH (:). CDPATH , .. ".". (/), CDPATH . -P (. -P set); -L . - $OLDPWD. 0, - 1.
command [-pVv] []
, . , PATH . -p, PATH, , . -V -v, . -v - , ; -V . -V -v, 0, , 1 . , 127. command .
compgen [] []
, , complete -p -r. . -F -C, , , .
, . , , .
0, , .
complete [-abcdefjkvu] [-o ] [-A ] [-G globpat] [-W _] [-P ] [-S ] [-X filterpat] [-F ] [-C ] [ ...]
complete -pr [ ...]
, . -p , . -r , - .
" ".
. -G, -W -X ( , , -P -S) , complete.
-o
, , comspec :
default
readline, compspec .
dirnames
, compspec .
filenames
readline, compspec , readline (, ). .
-A
:
alias
( -a);
arrayvar
-;
binding
readline;
builtin
( -b);
command
( -c);
directory
( -d);
disabled
;
enabled
;
export
( -e)
file
( -f)
function
;
helptopic
help;
hostname
, , HOSTFILE;
job
, ( -j);
keyword
( -k);
running
, ;
setopt
-o set;
shopt
, shopt;
signal
;
stopped
, ;
user
( -u);
variable
( -v);
-G globpat
globpat.
-W _
_ - IFS, . , .
-C
, .
-F
. - COMPREPLY.
-X filterpat
filterpat - . , , , filterpat, . ! filterpat ; , .
-P
.
-S
.
(0), , , ( -p -r), .
continue [n]
for, while, until select. n, n- . n 1. n , ( " "). 0, .
declare [-afFirx] [-p] [[=]]
typeset [-afFirx] [-p] [[=]]
/ . , . -p . -p, . -F ; . -F -f. :
-a
- (. "" ).
-f
.
-i
; (. " ").
-r
. unset.
-x
.
'+' '-' , , +a . , , local. 0, , "-f foo=bar", , , (. "" ), , , , , -f.
dirs [-clpv] [+n] [-n]
. . pushd; popd .
+n
n- , dirs . .
-n
n- , dirs . .
-c
, .
-l
; .
-p
.
-v
, .
, n , 0.
disown [-ar] [-h] [ ...]
. -h, , , SIGHUP SIGHUP . -a -r, . , -a ; -r . 0, .
echo [-neE] [ ...]
, . - 0. -n, . -e, . -E , . xpg_echo , echo . echo -- . echo :
a
()
b
c
e
f
n
r
t
v
\
\nnn
ASCII nnn ( )
xnnn
ASCII nnn ( )
enable [-adnps] [-f ] [ ...]
. , , . -n, , . , test, PATH , , "enable -n test". -f , . -d , -f. -p, . . -n , . -a, . -s, , POSIX. 0, .
eval [ ...]
. , eval. , eval 0.
exec [-cl] [-a ] [ []]
, . . . -l, , . login(1). -c . -a, . , , execfail, - . , . , 0. , 1.
exit [n]
n. n , . EXIT ( ).
export [-fn] [[=]] ...
export -p
. -f, . -p, , . -n . export 0, , -f , .
fc [-e ] [-nlr] [] []
fc -s [pat=rep] []
. , , . ( , ) ( , ). , ( "fc -l -10" 10 ), , . , -16 ( ) .
-n . -r . -l, . , . , FCEDIT EDITOR, FCEDIT . , vi. , .
pat rep. "r=fc -s", "r cc" , "cc", "r" .
, 0, . -e, , . , , , - fc 1.
fg []
. , . , , 1 , , , .
getopts _ []
getopts . _ , ; , , , . getopts , , , - OPTIND. OPTIND 1 . , getopts OPTARG. OPTIND . getopts , , .
, getopts , . OPTIND , , ?.
getopts , , getopts .
getopts . _ , . , . OPTERR 0, , _ .
, getopts ? , , OPTARG. getopts , OPTARG .
, getopts , ?, OPTARG , . getopts , :, OPTARG .
getopts 0, , , . , .
hash [-r] [-p ] []
, PATH. -p, , . -r . , . , .
help [-s] []
. , help , ; , . -s . 0, , .
history [n]
history -c
history -d
history -anrw []
history -p [ ...]
history -s [ ...]
, . , (*), . n n . , ; HISTFILE. :
-c
, .
-d
.
-a
"" ( , bash) .
-n
, , . , bash.
-r
.
-w
, .
-p
. . , .
-s
. .
0, , , , -d -p.
jobs [-lnprs] [ ... ]
jobs -x [ ... ]
. :
-l
.
-p
- , .
-n
, .
-r
.
-s
.
, . 0, .
-x, jobs , , .
kill [-s | -n | -] [pid | ] ...
kill -l [ | _]
(pid) . , , SIGKILL, . , SIG, . , SIGTERM. -l . -l , , , 0. _ -l - , , , . kill , , , , , .
let [ ...]
- , (. " "). 0, let 1, , 0.
local [] [[=] ...]
, . local , . local . local - . - 0, local , .
logout
.
popd [-n] [+n] [-n]
. . :
+n
n- , . : "popd +0" , "popd +1" - .
-n
n- , . : "popd -0" , "popd -1" - .
-n
, .
popd , dirs 0. popd , , - , .
printf []
. - , : , , , , , . printf(1), %b , , %q , .
, . , , , . 0 .
pushd [-n] []
pushd [-n] [+n] [-n]
, . , 0, . :
+n
, n- ( 0) , dir, .
-n
, n- ( 0) , dir, .
-n
, .
, .
pushd , dirs. , pushd 0 , . pushd 0, , .
pwd [-LP]
. , -P physical set. -L, . - 0, .
read [-ers] [-t ] [-a _] [-p ] [-n ] [-d delim] [ ...]
, - , , . , , . , IFS. (\) . :
-a _
_, 0. _ . .
-d delim
delim <_> .
-e
, readline (. "READLINE" ).
-n
read , .
-p
. .
-r
. . , .
-s
"" . , .
-t
read . , (pipe).
, REPLY. - 0, , .
readonly [-apf] [ ...]
; . -f, , . -a . -p, , . -p , . - 0, , -f , .
return [n]
n. n , , . , . (source), n, . ., 1.
set [--abefhkmnptuvxBCHP] [-o ] [ ...]
, . . , . $1, $2,... $n. -o:
-o _
_ :
allexport
. ( : -a)
braceexpand
(. "" ). . ( : -B)
emacs
emacs. , --noediting.
errexit
, (. " " ) . , until while, if, && ||, !. ( : -e)
hashall
, . . ( : -h)
histexpand
!. . ( : -H)
history
, " ". .
ignoreeof
, IGNOREEOF=10 (. " " ).
keyword
, . ( : -k)
monitor
. . , (. " " ). , , , . ( : -m)
noclobber
, bash >, >& <>. , >| >. ( : -C)
noexec
, . . . ( : -n)
noglob
. ( : -f)
notify
, . . ( : -b)
nounset
. , , . ( : -u)
onecmd
. ( : -t)
physical
, cd, . , . , bash , . ( : -P)
posix
bash POSIX 1003.2, , ( posix).
privileged
. $ENV $BASH_ENV , , SHELLOPTS . (), , -p , . -p , . . ( : -p)
verbose
. ( : -v)
vi
vi.
xtrace
PS4, - . ( -x)
-o _, . +o _, set, .
:
-a
, "allexport".
-b
, "notify".
-e
, "errexit".
-f
, "noglob".
-h
, "hashall".
-k
, "keyword".
-m
, "monitor".
-n
, "noexec".
-p
, "privileged".
-t
, "onecmd".
-u
, "nounset".
-v
, "verbose".
-x
, "xtrace".
-B
, "braceexpand".
-C
, "noclobber".
-H
, "histexpand".
-P
, "physical".
--
, . , , (-).
-
, ( ). -x -v . , .
, . + - , . . $-. - 0, .
shift [n]
n+1... $1... $#-n+1 $# . n , $#. n 0, . n , 1. n $#, . - , n $# 0 .
shopt [-pqsu] [-o] [_ ...]
, . -p, , , . -p , . :
-s
() .
-u
() .
-q
( ); , . -q _, - 0, , 0 .
-o
_ -o set.
-s -u , , . , shopt ().
- 0, , 0 . - 0, .
shopt:
cdable_vars
cd , , - , - .
cdspell
, cd . , . , . .
checkhash
, bash , , . , .
checkwinsize
, bash , , LINES COLUMNS.
cmdhist
, bash . .
dotglob
, bash , (.).
execfail
, , , exec. , exec .
expand_aliases
, , "". .
extglob
, , " ".
histappend
, , HISTFILE, .
histreedit
readline, .
histverify
readline, . , readline .
hostcomplete
readline, bash , @, (. "" "READLINE" ). .
huponexit
, bash SIGHUP .
interactive_comments
, , #, (. "" ). .
lithist
, cmdhist, , , .
mailwarn
, bash , , "The mail in has been read".
no_empty_cmd_completion
readline, bash PATH , .
nocaseglob
, bash (. " " ).
nullglob
, bash , (. " " ), .
progcomp
, (. " ").
promptvars
, , " " . .
restricted_shell
, (. " " ). . , , .
shift_verbose
, shift , .
sourcepath
, source (.) PATH , , . .
xpg_echo
, echo .
suspend [-f]
, SIGCONT. -f , , - . - 0, , -f - , .
test
[ ]
0 1, . . , " ".
, .
!
, .
( )
. .
1 -a 2
, 1, 2.
1 -o 2
, 1 2.
test [ , .
0
.
1
, .
2
- !, . - , " ", , . , .
3
- , " ", , . - !, - . - (, - ), . , . -a -o .
4
- !, - . , .
5
.
times
. - 0.
trap [-lp] [] [ ...]
. -, (, ). - , . -p, trap, . -p, trap (), . , <signal.h>, . EXIT ( 0), - . DEBUG, - (. " " ). -l . , , . . - 1, ; , trap 0.
type [-atp] [ ...]
, . -t, type alias, keyword, function, builtin file, , , , , , . , 1. -p, type , , , . , -p , , PATH . -a, type , . , -p. -a, . type 0, , 1 .
ulimit [-SHacdflmnpstuv []]
, , . unlimited. -H -S , . ; . -H -S , , . , , -H. , . :
-a
.
-c
- (core dump).
-d
.
-f
, .
-l
, (locked) .
-m
.
-n
( ).
-p
512- ( ).
-s
.
-t
.
-u
.
-v
, .
, ( -a ). , -f. 1024 , -t , -p 512- , -n -u ( ""). - 0, , ( unlimited) .
umask [-p] [-S] []
. , ; - , chmod(1). -S, . -S ; . -p, , , . - 0, , 1 .
unalias [-a] [ ...]
. -a, . 0, , .
unset [-fv] [ ...]
() . -v, . . -f, . , . RANDOM, SECONDS, LINENO, HISTCMD, FUNCNAME, GROUPS DIRSTACK, , . - 0, , .
wait [n]
. n ; , . n , , . n , - 127. , , .

bash rbash -r , . . bash, :
-
cd;
-
SHELL, PATH, ENV BASH_ENV;
-
/ ;
-
, , . (source);
-
, , -p hash;
-
;
-
SHELLOPTS ;
-
>, >|, <>, >&, &> >>;
-
exec ;
-
-f -d enable;
-
-p command;
-
set +r set +o restricted.
.
, (. " " ), rbash , .

Bash Reference Manual, Brian Fox and Chet Ramey
The Gnu Readline Library, Brian Fox and Chet Ramey
The Gnu History Library, Brian Fox and Chet Ramey
Portable Operating System Interface (POSIX) Part 2: Shell and Utilities, IEEE
sh(1), ksh(1), csh(1)
emacs(1), vi(1)
readline(3)

/bin/bash
bash.
/etc/profile
, .
~/.bash_profile
, .
~/.bashrc
.
~/.bash_logout
, .
~/.inputrc
readline.

(Brian Fox), Free Software Foundation, bfox@gnu.org
(Chet Ramey), Case Western Reserve University, chet@ins.CWRU.Edu

bash, . , , bash.
, , , bashbug . , , ! "" bug-bash@gnu.org Usenet gnu.bash.bug.
:
bash,
,
, ,
,
"", .
bashbug .
chet@ins.CWRU.Edu.
avsdov@yahoo.com.

.
bash sh, , POSIX.
.
/.
'a ; b ; c' . , . , , , .
$(...) , . .
() .



, :
RSS