BASH(1) BASH(1)
[] []
sh-
. Bash
C (ksh, csh)
Bash
IEEE POSIX (IEEE Working Group 1003.2)
.
bash (flag) ( : option , flag , parameter ,
argument ):
-c -c
,
.
, $0
.
-i -i
, (interactive) .
-s -s
.
.
- -
. -
.
- --
.
Bash
.
.
-norc
~/.bashrc
.
sh
.
-noprofile
/etc/profile
~/.bash_profile, ~/.bash_login, ~/.profile
. bash
.(
INVOCATION
).
-rcfile ( INVOCATION
)
~/.bashrc
.
-version bash
.
-quiet .(
-login bash
.
-nobraceexpansion
. ( (Brace)
).
-nolineediting
GNU readline
.
-posix POSIX 1003.2 bash
-s
, bash
, is invoked in this fashion, $0
. Bash
.
Bash
.
(blank)
.
(word) . (token)
.
(name) , (_)
. (identifier)
.
(metacharacter)
(quote) .
:
| & ; ( ) < >
(control operator)
. :
|| & && ; ;; ( ) | <newline>
.
case
for
: (
)
! case do done elif else esac fi for function if in select then until
while { }
(SHELL GRAMMAR)
(, : optional
.)
. .
.
.IR n .
128+n .
|
.
:
[ ! ] [ | 2 ... ]
2
.
. (
).
!
NOT .
.
.(,
.)
(Lists)
;, &, &&, ||
;, &, <>
.
, &&
||
;
&
.
&
,
.
0 . ;
;
.
&&
||
AND OR . AND .
&& 2
2
0 .
OR .
|| 2
2
0 . AND OR
.
:
() .
.
.
{ ; } . known as a
.
.
for [ in ; ] do ; done
in .
. in for
. ( PARAMETERS
).
select [ in ; ] do ; done
in .
. in . ( PARAMETERS
). PS3
.
.
(null) . REPLY
. break
return
. select
0 .
case in [ [ | ] ... ) ;; ] ... esac
case ,
. ( Pathname Expansion
).
.
.
0 .
.
if then [ elif then ] ... [ else ] fi
if
. 0 then
. 0 elif .
0 .
while do done
until do done
while
0 do
. until while
. do
0 . while until do
.
0 .
[ function ] () { ; }
. { }
.
( FUNCTIONS
- set -o interactive-comments
, #
. -o interactive-comments
.
.
. ( : Quote
DEFINITIONS
. 3 : (escape) ,
, .
(\) <>
. \<> \<> ( :
\<> )
.(, .)
.
.
. $, `,
\
. $
`
.
: $, `, ", \,
<>.
.
*
@
. ( PARAMETERS
).
. , , (Special Parameters)
.
.
. .
unset
. ( (SHELL BUILTIN COMMANDS)
).
A
.
=[]
If
.
, , , ,
, .
-i
(
declare
)
$[...] .
"$@" .
.
0 .
set
.
.
. ( (FUNCTIONS)
).
1
. ( (EXPANSION)
).
.
.
* 1 .
.
IFS
.
, ``$*'' ``$1c$2c...''
.
c
IFS
. IFS
.
@ 1 .
.
`` $@''
``$1'' ``$2'' ... .
``$@'' $@
.(, .)
# .
? .
- set
( -i ) .
$ ID . ()
ID .
! () ID .
0 . . bash
, $0
. bash
-c
$0
( ) .
bash
0 .
_ ( ) .
export
. ( : export )
:
PPID ID.
PWD cd
.
OLDPWD cd
.
REPLY read
UID ID . .
EUID ID . .
BASH bash
.
BASH_VERSION
bash (instance) .
SHLVL bash
1
RANDOM .
RANDOM
. If RANDOM
unset .
.
SECONDS
. SECONDS
,
. SECONDS
unset .
.
LINENO
(1 ) .
, .
( .)
. If LINENO
unset .
.
HISTCMD
. HISTCMD
unset .
.
OPTARG getopts
(
).
OPTIND getopts
(
).
HOSTTYPE
bash
.
.
OSTYPE bash
.
.
.
bash
; .
IFS (Internal Field Separator)
read
. that is used
``<><><>''.
PATH .
. ( (COMMAND EXECUTION)
).
bash
.
``/usr/gnu/bin:/usr/local/bin: /usr/ucb:/bin:/usr/bin:''
.
HOME ; cd
.
CDPATH cd
. cd
``.:~:/usr'' .
ENV bash ,
.bashrc
. The value of ENV
, ,
.
PATH
.
MAIL MAILPATH
, bash
.
MAILCHECK
( ) bash
.
60 .
unset .
MAILPATH
.
`?' . $_ . :
MAILPATH='/usr/spool/mail/bfox?"You have mail":~/shell-mail?"$_
has mail!"'
Bash
. ( , /usr/spool/mail/$USER).
MAIL_WARNING
bash
, , ``The mail in has been read'' .
PS1 ( PROMPTING
)
. ``bash\$ ''.
PS2 2 .
``> ''.
PS3 select
. ( ).
PS4 bash
. PS4
.
``+ ''.
HISTSIZE
( (HISTORY)
) 500.
HISTFILE
. ( HISTORY unset .
HISTFILESIZE
.
(truncate). 500.
OPTERR 1 bash
getopts
. ( ).
OPTERR
1 .
PROMPT_COMMAND
.
IGNOREEOF
EOF
.
EOF
bash
.
10 . EOF
. .
TMOUT 0
Bash
.
FCEDIT fc
.
FIGNORE
. ( READLINE ) FIGNORE
INPUTRC
~/.inputrc
readline . ( READLINE ).
notify , If set, bash
. ( set
-b
)
history_control
HISTCONTROL
ignorespace
. ignoredups
. ignoreboth
. unset (parser) .
command_oriented_history
, bash
.
.
glob_dot_filenames
, bash
`.' .
allow_null_glob_expansion
, bash
( )
histchars
. ( )
(history expansion character) , `! .
(quick substitution)
.
`^' .
, `#' .
.
(parser)
.
nolinks
,
. .
bash
cd
set
-P . ( )
hostname_completion_file
HOSTFILE
/etc/hosts
.
;
bash
.
noclobber
, bash
>, >&, <>
. >
>|
. ( set
-C .)
auto_resume
.
,
.
;
.
. exact
,
; substring
,
; substring
%? job id
. ( (JOB CONTROL)
)
; % job id
.
no_exit_on_failed_exec
, exec
. exec
.
cdable_vars
cd
,
.
.
: (brace expansion), (tilde expansion), , , , , .
, , , ,
( ), , .
(process substitution)
.
, ,
; .
``$@'' . (
).
(Brace Expansion)
.
. .
preamble
postamble
. preamble postamble .
. ;
.
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, (Bourne shell) . sh
Bash
.
sh
file{1,2} file{1,2} . bash
file1 file
.
sh
bash
-nobraceexpansion
. -nobraceexpansion (
)
set
+o braceexpand
. (
)
(Tilde Expansion)
(`~') , ( ) HOME
. HOME
`+' , `+' PWD
. `-' OLDPWD
.
.
.
:
=
.
. PATH, MAILPATH, CDPATH
(Parameter Expansion)
`$' , , .
.
.
${} .
,
.
, , , ,
. Bash
unset ;
unset .
${:-} . If
unset ,
.
.
${:=} .
unset ,
.
.
.
${:?} unset . If
unset , (
)
.
.
${:+} .
unset ,
.
${#} . *
@
, *
.
${#}
${##}
.
,
(``#'' )
(``##'' ) .
${%}
${%%}
.
,
(``%'' )
(``%%'' ) .
.
:
$()
``
Bash
. .
, $, `, \
. $()
; .
.
.
,
.
.
:
$[]
$(())
The
.
.
, , .
.
(ARITHMETIC EVALUATION)
.
bash
.
(FIFOs)
/dev/fd . <()
>() .
FIFO /dev/fd
.
. >()
. <()
.
.IR " " , ,
.
, , .
IFS
(delimeter)
. IFS
<><><>
, IFS
. IFS
, IFS
,
. IFS ( IFS
). IFS
IFS
IFS
. IFS
. IFS
. IFS
unset .
("" '') .
.
.
-f
, bash
*, ?, [
.
allow_null_glob_expansion
unset .
, .
,
``.''
glob_dot_filenames
, .
.
``.''
.
:
* .
? .
[...] .
;
( )
. [
!
^
. -
]
.
,
\, `, "
.
.
.
.
.
<
( 0 ) .
>
( 1 ) .
, ,
, , , , bash
.
. ,
ls > dirlist 2>&1
dirlist
ls 2>&1 > dirlist
dirlist
. dirlist
.
n
n
( 0)
.
:
[n]<
n
n
( 1)
.
:
[n]>
>|
, set
-C
. (
noclobber
)
n
n
( 1)
.
.
:
[n]>>
Bash
( 1) ( 2)
.
:
&>
and
>&
. Of the two forms, the first is preferred.
.
> 2>&1
HERE
( )
.
.
HERE :
<<[-]
HERE-
, , ,
.
HERE .
HERE , ,
. , \<>
\, $, `
\
.
<<- ,
.
HERE
.
[n]<&
.
, n
.
-
,
n
. n
, ( 0) .
[n]>&
. n
( 1) .
, n
[n]<>
n
n
.
.
.( .)
.
#
. 0 .
local
.
return
. #
.
declare
typeset
-f
.
export
-f
export .
. .
alias
unalias
(aliases)
. (
).
. = .
.
. , ls
ls -F
bash
.
,
.
alias
unalias
.
csh
.
.
.
. Bash
. . ,
.
.
.
.
.
.
.
(JOB CONTROL)
( (suspend))
( (resume)) bash
.
. jobs
. bash
( ) ,
:
[1] 25647
1
ID 25647 . Bash
.
ID .
( ID
ID ) SIGINT
.
.
ID ID
;
.
.
SIGTTIN (SIGTTOU)
.
bash
bash
.
( ^Z, Control-Z) bash
. (delayed suspend)
( ^Y, Control-Y) bash
. bg
fg
kill
. ^Z
.
. %
.
n
%n
.
.
, %ce
ce
. job. bash
.
%?ce
, ce
.
bash
. %%
%+
(current job)
. (previous job)
%-
.
( , jobs
) +
,
-
.
: %1
``fg %1'' ,
1 .
``%1 &''
1 ``bg %1''
.
.
, bash
. set
-b
, bash
. (
notify
.)
bash
, .
jobs
.
.
bash SIGTERM
( kill 0 ), SIGINT
.( wait )
bash SIGQUIT
.
bash
SIGTTIN, SIGTTOU, SIGTSTP
.
bash
.
( &
) SIGINT , SIGQUIT
.
SIGTTIN, SIGTTOU, SIGTSTP
.
(COMMAND EXECUTION)
, ,
.
.
FUNCTIONS
.
.
.
, bash
PATH
.
0 .
.
0 ,
.
.
.
,
. (
hash
)
#!
,
.
.
,
. =
- .
.
,
export
. export
declare -x
.
unset
export
declare -x
.
.
.
-k
( set
)
.
bash
_
.
0 . 0
. 0 .
bash 128+ .
127 . 126 .
bash 0 ,
.
exit .
, bash
PS1
PS2
. Bash
-
:
\t HH:MM:SS
\d " " (, "Tue May 26")
\n
\s , $0
( )
\w
\W
\u
\h
\#
\!
\$ UID 0 if the effective UID is 0, a #,
$
\nnn nnn
\\
\[ .
.
\] .
:
, ( (HISTORY)
) .
, , , ,
.
-nolineediting
, .
. vi .
.
C- . C-n -N
M- M-x -X . (
M-x ESC x .
x
. ESC . M-C-x ESC--x
x
.)
- ~/.inputrc
.
INPUTRC
~/.inputrc
.
.
M-Control-u: universal-argument
C-Meta-u: universal-argument
~/.inputrc
M-C-u readline universal-argument
.
: RUBOUT, DEL, ESC, LFD, NEWLINE, RET, RETURN, SPC, SPACE, TAB.
, readline
.()
readline .
INPUTRC
. unset ~/.inputrc 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 .
"\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
.
:
\C-
\M-
\e
\\
\" "
\' '
.
. " '
.
Bash
bind
readline . set
-o
. (
)
Readline .
inputrc
set -
.
readline On
Off
.
:
horizontal-scroll-mode (Off)
On readline
.
editing-mode (emacs)
readline emacs vi
. editing-mode
emacs
vi
.
mark-modified-lines (Off)
On (*) .
bell-style (audible)
readline . none . visible . audible .
comment-begin (``#'')
vi-comment
vi
meta-flag (Off)
On 8
.( .)
convert-meta (On)
On 8 8 ASCII
.(
output-meta (Off)
On 8
.
completion-query-items (100)
possible-completions
. 0 .
;
.
keymap (emacs)
readline . emacs, emacs-standard, emacs-meta, emacs-ctlx, vi,
vi-move, vi-command, vi-insert
. vi vi-command ; emacs emacs-standard .
emacs ; editing-mode
.
show-all-if-ambiguous (Off)
. on
.
expand-tilde (Off)
on .
Readline C . 3
.
$if $if
, , readline
.
; .
mode $if mode= readline vi
. , set keymap readline emacs-standard emacs-ctlx
.
term term=
. =
- sun
sun
sun-cmd
.
application
application . readline
.
.
, bash
:
$if Bash
# Quote the current or previous word
"\C-xq": "\eb\"\ef\""
$endif
$endif $if .
$else $if .
Readline
.
. (, kill-line)
.
.
(kill) ,
.(yanking )
kill-ring .
yank .
kill-ring .
.
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 .
shell-expand-line (M-C-e)
.
, .
.
history-expand-line (M-^)
.
.
insert-last-argument (M-., M-_)
yank-last-arg
operate-and-get-next (C-o)
. .
delete-char (C-d)
. ,
C-d
EOF
.
backward-delete-char (Rubout)
. kill-ring
.
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)
( ) .
.
(Killing, Yanking)
kill-line (C-k)
.
backward-kill-line (C-x C-Rubout)
.
unix-line-discard (C-u)
.
kill-whole-line
.
kill-word (M-d)
. forward-word .
backward-kill-word (M-Rubout)
. forward-word
unix-word-rubout (C-w)
.
backward-kill-word .
delete-horizontal-space
.
.
yank (C-y)
kill ring .
yank-pop (M-y)
kill-ring . yank
yank-pop
.
digit-argument (M-0, M-1, ..., M--)
. M-- .
universal-argument
4 . 1 .
4 . .
complete (TAB)
. Bash
($ ), (~ ), (@ ) ( )
.
possible-completions (M-?)
.
insert-completions
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)
abort (C-g)
. ( bell-style
)
do-uppercase-version (M-a, M-b, ...)
.
prefix-meta (ESC)
. ESC f
-f
.
undo (C-_, C-x C-u)
.
revert-line (M-r)
.
undo
.
tilde-expand (M-~)
.
dump-functions
readline .
inputrc
display-shell-version (C-x C-v)
bash
.
.
HISTSIZE
( 500) .
. (
) command_oriented_history
HISTCONTROL
.
, HISTFILE
. ( ~/.bash_history). HISTFILESIZE
HISTFILE
.
fc ( ) . history
.
HISTSIZE
HISTFILE
. HISTFILE
unset .
(HISTORY EXPANSION)
csh
.
. +H option to the set
+H
. ( ) .
.
.
.
(words) .
.
(\) ( !) .
. (
histchars
)
(Event Designators)
.
! , , = (
.
!! . `!-1' .
!n n
.
!-n n
.
! .
!?[?] .
^1^2^ . 1
2
. ``!!:s/1/2/'' . ((Modifiers) ).
!# .
:
.
^, $, *, %
.
0( ) .
0 ( ) 0 . .
n n .
^ 1 .
$ .
% `??'
x-y ; `-y' `0-y' .
* 0 . `1-$'
*
; .
x* x-$ .
x- x* x-$ .
(Modifiers)
`:' .
h .
r .xxx .
e .
t .
p .
q .
x q
.
.
s///
. / .
.
.
&
.
& .
& .
g . `:s' (, `:gs///') `:&' . If used with `:s' /
.
(ARITHMETIC EVALUATION)
. ( let )
long . 0
.
- +
! ~
* / % , ,
+ - ,
<< >> ,
<= >= < >
== != ,
& AND
^ (exclusive) OR
| OR
&& AND
|| OR
= *= /= %= += -= <<= >>= &= ^= |=
;
.
0 8 . 0x 0X 16 . [base#]n . base 2 36 10 n
. base 10 .
.
.
(SHELL BUILTIN COMMANDS)
: [] ;
.
0 .
. []
source []
.
.
PATH
. PATH
. PATH
.
.
.
( 0)
.
alias [[=] ...]
Alias =
.
.
.
.
.
bg [] &
.
. bg
,
0 .
bind [-m ] [-lvd] [-q ]
bind [-m ] -f
bind [-m ] :
readline
, readline
.
.inputrc
;
, '"\C-x\C-r": re-read-init-file'.
:
-m
.
emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-
move, vi-command,
vi-insert
. vi vi-command ; emacs emacs-standard .
-l readline .
-v .
-d .
-f filename .
-q .
0 .
break [n]
for, while, until
. n n . n
>= 1 . n
. break
0 .
builtin - []
.
.
cd . -
.
cd [] . HOME
CDPATH
.
(:) . CDPATH
``.'' .
(/) CDPATH
.
-
$OLDPWD
.
, .
command [-pVv] [ ...]
. PATH
. are executed. If the -p
PATH
. -V
-v
. -v
; -V
. --
. -V
-v
0, 1 .
127 . command
.
continue [n]
for, while, until
. n
, n . n
>= 1 . n
(` ' ) continue
0 .
declare [-frxi] [[=]]
typeset [-frxi] [[=]]
.
.
.
-f
-r .
.
-x export .
-i ; (
) .
`-' `+' . local
. , "-f foo=bar" ,
,
, -f
0 .
dirs [-l] [+/-n]
.
pushd
; popd
.
+n dirs
n . 0 .
-n dirs
n . 0 .
-l ;
.
n
0 .
echo [-neE] [ ...]
. 0 . -n . -e . -E
.
\a ()
\b
\c
\f
\n
\r
\t
\v
\\
\nnn ASCII nnn (8)
enable [-n] [-all] [ ...]
.
-n ;
. , PATH
test
``enable -n test'' .
. -n . -all , enable
-all
-a
.
0 .
eval [ ...]
.
eval
.
eval
.
exec [[-] []]
.
.
.
-
0 . no_exit_on_failed_exec
.
0 .
exit [n]
n . n
.
EXIT
(trap) .
export [-nf] [[=]] ...
export -p
export . -f
.
-p
export . -n
export . --
.
.B
-f
export
0 .
fc [-e ] [-nlr] [] []
fc -s [=] []
. ,
.
( ) (
) .
( fc -l -10
10 )
. If
-16 .
-n
. -r
. -l
.
.
FCEDIT
FCEDIT
EDITOR
.
vi
.
,
. ``r=fc -s'' . ``r cc'' ``cc'' ``r''
.
0 . -e
.
fc
fg [] .
.
.
.
getopts []
getopts
.
;
.
, getopts
.
. OPTIND
. OPTIND
1 .
getopts
OPTARG
.
OPTIND
;
getopts
.
getopts
.
.
. OPTERR
0
.
, getopts
? ,
OPTARG
unset . getopts
OPTARG
.
getopts
(?)
OPTARG
unset . getopts
(:)
OPTARG
.
getopts
getopts
. getopts
.
.
hash [-r] []
,
. -r
.
. --
.
.
help []
.
, help
;
.
0 .
history [n]
history -rwan [filename]
, . *
. n
n
. , ; HISTFILE
. :
-a ``'' ( bash
) .
-n
. bash
.
-r .
-w .
0 .
jobs [-lnp] [ ... ]
jobs -x [ ... ]
. -l
ID ; -p
ID . -n
.
, .
0 .
-x
, jobs
ID
.
kill [-s | -] [pid | ] ...
kill -l []
pid
.
SIGKILL
.
, SIG
.
, SIGTERM
. -l
. -l
,
0 . --
. kill
.
.
let [ ...]
.(
).
0 , let
1 ; 0 .
local [[=] ...]
. local
,
(scope) .
, local
. local
. local
0 .
logout .
popd [+/-n]
.
cd
+n dirs
n . 0 .
, ``popd +0'' , ``popd +1'' .
-n dirs
n . 0 .
, ``popd -0'' , ``popd -1'' .
popd
, dirs
0 . popd
, ,
.
pushd []
pushd +/-n
,
.
, .
0 .
+n n ( dirs
)
. )
-n n ( )
.
.
pushd
, dirs
.
, pushd
cd , 0 .
, pushd
, , 0 .
pwd . set
-P
. (
nolinks
.) above).
0.
read [-r] [ ...]
. IFS
.
REPLY
.
0 . -r
-
readonly [-f] [ ...]
readonly -p
. -f
,
.
-p
, . --
.
.B -f
0 .
return [n]
n
. n
.
. (source) ,
n
.
.
set [--abefhkmnptuvxldCHP] [-o ] [ ...]
-a export
-b
. (
notify )
-e - ( ) 0 .
until
while
, if
, &&
, or ||
!
.
-f .
-h .
.
-k ,
-m () . .
. ( ).
.
-n .
. .
-o - - :
allexport
-a
.
braceexpand
. (
) .
emacs .
-nolineediting
, .
errexit -e
histexpand
-H
ignoreeof
`IGNOREEOF=10' . ( ).
interactive-comments
#
. ( ).
monitor -m
noclobber
-C
noexec -n
noglob -f
nohash -d
notify -b
nounset -u
physical
-P
posix POSIX 1003.2 bash POSIX
.
privileged
-p
verbose -v
vi vi .
xtrace -x
- .
-p privileged
.
$ENV
, .
() ID () ID
. , ID ,
ID .
-t .
-u .
,
0 .
-v .
-x -
, bash PS4,
.
-l for [in ]
. ( ).
-d .
.
-C `noclobber=' . ( ).
-H !
.
.
-P ,
cd
.
.
-- unset.
, -
.
- , -x
-v
.
, .
, . - + .
.
$-
.
, n
$1, $2, ... $n
.
.
, .
shift [n]
n+1 $1 ....
. $# $#-n+1 unset. n
0 , . n
1 . n
$# . n
$# , . n
$#
0 0 ;
0 .
suspend [-f]
SIGCONT
. -f
;
.
-f
0 .
test
[ ]
0 () 1 () .
.
.
.
.
/dev/fd/n ,
n .
-b .
-c .
-d .
-e .
-f .
-g set-group-id .
-k ``(sticky)'' .
-L f .
-p (named) .
-r .
-s 0 .
-S .
-t fd fd ( ) .
-u set-user-id .
-w .
-x .
-O (effective) ID .
-G ID .
1 -nt 2
1 ( ) 2 .
1 -ot 2
1 2 .
1 -ef 2
1 2 .
-z 0 .
-n
0 .
1 = 2 .
1 != 2 .
! .
1 -a 2 1
2
.
1 -o 2 1
2
.
1 2 -eq, -ne, -lt, -le, -gt,
-ge
.
1 2 , , , , , . 1
2
, -l
.
times ,
. 0 .
trap [-l] [] []
.
- ,
. ( )
.
<signal.h> ,
.
EXIT (0)
.
, trap
. -l
. --
.
.
.
trap
.
type [-all] [-type | -path] [ ...]
,
. -type
, type
, , , , , alias, keyword, function, builtin,
file
.
. -path
, type
, -type
file
.
, -path
PATH
. -all
, type
. -path
, . -all
. type
-all, -type,
-path
-a, -t,
-p
. --
. type
ulimit [-SHacdfmstpnuv []]
Ulimit
.
unlimited
. H S (hard) (soft) .
;
. H S
H , .
.
:
-a .
-c
-d
-f
-m (resident size)
-s
-t CPU
-p 512 ( )
-n ( .)
-u
-v
--
.
, .( -a
.)
-f
.
-t, 512 -p,
-n
-u
, 1024 .
, unlimited
0 .
umask [-S] []
.
8 . chmod(1)
.
, -S
,
. -S
;
8 . --
.
0 .
unalias [-a] [ ...]
. -a
.
.
unset [-fv] [ ...]
,
, -f
. --
. PATH, IFS, PPID, PS1, PS2, UID,
EUID
unset . RANDOM, SECONDS, LINENO,
HISTCMD
unset,
.
unset , .
wait [n]
. n
ID ;
. n
, 0 . n
127 .
,
0 -
.
(interactive)
( isatty(3)
.) -i
. bash
PS1
$-
i .
:
(-noprofile ):
/etc/profile , (source).
~/.bash_profile .
~/.bash_login .
~/.profile .
:
~/.bash_logout .
:
(-norc -rcfile ):
~/.bashrc .
:
:
if the environment variable ENV is non-null, expand
ENV , ,
. .
if [ "$ENV" ]; then . $ENV; fi
PATH .
POSIX , bash ENV
BASH_ENV .
bash sh
,
sh
. , /etc/profile
~/.profile,
. -noprofile
. sh
.
-posix
bash
posix
POSIX .
ENV
; .
Bash Features, Brian Fox and Chet Ramey
The Gnu Readline Library, Brian Fox and Chet Ramey
The Gnu History Library, Brian Fox and Chet Ramey
A System V Compatible Implementation of 4.2BSD Job Control, David
Lennert
Portable Operating System Interface (POSIX) Part 2: Shell and Utili-
ties, IEEE
sh(1), ksh(1), csh(1)
emacs(1), vi(1)
readline(3)
/bin/bash
bash
/etc/profile
~/.bash_profile
~/.bashrc
~/.inputrc
readline
Brian Fox, Free Software Foundation ( )
bfox [AT] ai.Edu
Chet Ramey, Case Western Reserve University
chet [AT] ins.Edu
.
bash
.
bashbug
.
!
`' bug-bash@prep.ai.MIT.Edu
gnu.bash.bug
.
:
bash
'recipe'
bashbug
3 .
chet [AT] ins.Edu
.
.
bash
sh
.
POSIX
.
.
,
Man-Yong Lee, ALZZA LINUX
yong [AT] alzzalinux.com
geoman [AT] nownuri.net
.
GNU 1995 May 5 BASH(1)