BASH(1) General Commands Manual BASH(1) NAME bash - GNU Bourne-Again SHell (GNU "Bourne") (SYNOPSIS) bash [options] [file] (COPYRIGHT) Bash is Copyright (C) 1989-2002 by the Free Software Foundation, Inc. (DESCRIPTION) Bash sh Bash Korn C Shell (ksh csh) Bash IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2 shell ) (OPTIONS) set (option) bash -c string -c string string (argument) (positional parameter $0 ) -i -i shell ( interactive ) -l bash shell (login shell) ( (INVOCATION) ) -r -r shell ( restricted ) ( shell(RESTRICTED SHELL) ) -s -s shell -D $ C POSIX -n [-+]O [shopt_option] shopt_option shopt ( shell (SHELL BUILTIN COMMANDS) ) shopt_option-O +O shopt_optionshopt +O -- -- -- - Bash --dump-po-strings -D GNU gettext po () --dump-strings -D --help --init-file file --rcfile file shell file ~/.bashrc ( (INVOCATION) ) --login -l --noediting shell GNU readline --noprofile /etc/profile ~/.bash_profile, ~/.bash_login, ~/.profile bash shell ( (INVOCATION) ) --norc shell / ~/.bashrc shell sh --posix POSIX 1003.2 bash (posix mode) --restricted shell ( shell(RESTRICTED SHELL) ) --rpm-requires -n Backticks, [] tests, evals --verbose -v --version bash (ARGUMENTS) -c -s shell bash $0 Bash Bash 0 shell PATH (INVOCATION) login shell shell - --login shell interactive shell -c ( isatty(3) ) shell -i shell bash PS1 $- i shell bash bash (~,tilde) EXPANSION Tilde Expansion bash shell shell --login /etc/profile ~/.bash_profile, ~/.bash_login, ~/.profile, --noprofile shell shell bash ~/.bash_logout shell shell bash ~/.bashrc --norc --rcfile file bash file ~/.bashrc bash shell BASH_ENV Bash if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi PATH bash sh (mimic) sh POSIX shell , --login , /etc/profile ~/.profile, . --noprofile . sh shell , bash ENV, , . sh shell , --rcfile . sh shell . sh , bash posix . bash posix ,( --posix ), POSIX . , shell ENV ,. . Bash shell , rshd . bash rshd , ~/.bashrc , . sh ,. --norc , --rcfile , rshd , shell. shell () id () id , - ,, shell . SHELLOPTS . id id. - ,, id. (DEFINITIONS) . blank tab . word , shell . token name ,,. word identifier. metacharacter , , . : | & ; ( ) < > space tab control operator token(), . : || & && ; ;; ( ) | ("RESERVED WORDS") Reserved words() shell . , , ( shell("SHELL GRAMMAR") ), case for : ! case do done elif else esac fi for function if in select then until while { } time [[ ]] shell("SHELL GRAMMAR") Simple Commands simple command() (), blank() , control operator . , 0 . . simple command , 128+n, signal() n . Pipelines pipeline() | : [time [-p]] [ ! ] command [ | command2 ... ] command command2 ( REDIRECTION ) ! shell time -p POSIX TIMEFORMAT Shell Variables TIMEFORMAT ( shell ) Lists list() ;, &, &&, || , ;, &, . && || ; &, & , shell shell shell 0 ; shell && || AND OR AND command1 && command2 command2 command1 0 OR command1 || command2 command2 command1 0 AND OR Compound Commands compound command() (list) list shell shell { list; } list shell group command() ( { } reserved words() (cause a word break) ((expression)) expression (ARITHMETIC EVALUATION) 0 1 let "expression" [[ expression ]] 0 1 expression CONDITIONAL EXPRESSIONS (primaries) [[ ]] tilde == != Pattern Matching() 0 1 ( expression ) expression ! expression expression expression1 && expression2 expression1 expression2 expression1 || expression2 expression1 expression2 &&() || expression2 expression1 for name [ in word ] ; do list ; done in name list in word for (positional parameter PARAMETERS ) list in 0 for (( expr1 ; expr2 ; expr3 )) ; do list ; done expr1 (ARITHMETIC EVALUATION) expr2 0 expr2 list expr3 1 list false select name [ in word ] ; do list ; done in in word ( PARAMETERS ) PS3 name EOF name REPLY. list break select list 0 case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac case word, pattern ( Pathname Expansion ) 0 if list; then list; [ elif list; then list; ] ... [ else list; ] fi if list 0then list elif 0 then list else list 0 while list; do list; done until list; do list; done while do list 0 until while do list while until do list 0 [ function ] name () { list; } name body { } list name ( FUNCTIONS ) (COMMENTS) shell shopt interactive_comments shell # interactive_comments shell shell ( shell (SHELL BUILTIN COMMANDS) ) (QUOTING) Quoting DEFINITIONS metacharacters shell history expansion ! (escape character), (\) escape character \ \ () $, `, \ $ ` $, `, ", \, . * @ ( PARAMETERS ) $'string' string ANSI C \a alert (bell) \b backspace \e an escape character Esc \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \\ backslash \' single quote \nnn nnn () \xHH HH () \cx ctrl-x $ $ (locale) C POSIX (PARAMETERS) parameter name, Special Parameters shell variable name value attibutes declare ( shell (SHELL BUILTIN COMMANDS) declare ) unset ( shell (SHELL BUILTIN COMMANDS) ). variable name=[value] value values ( EXPANSION ) integer value $((...)) ( Arithmetic Expansion ) Special Parameters "$@" declare, typeset, export, readonly, local Positional Parameters positional parameter 0 shell set shell ( FUNCTIONS ) ( EXPANSION ) Special Parameters shell * 1 IFS "$*" "$1c$2c..." c IFS IFS IFS @ 1 "$@" "$1" "$2" ... "$@" $@ () # ? - set shell ( -i ) $ shell ID () shell shell ID shell ! () 0 shell shell shell bash $0 bash -c $0 bash 0 _ shell shell shell Shell Variables shell BASH bash BASH_VERSINFO bash BASH_VERSINFO[0] (release). BASH_VERSINFO[1] (version). BASH_VERSINFO[2] BASH_VERSINFO[3] BASH_VERSINFO[4] (, beta1). BASH_VERSINFO[5] MACHTYPE BASH_VERSION bash. COMP_CWORD ${COMP_WORDS} ( Programmable Completion ) shell COMP_LINE shell COMP_POINT ${#COMP_LINE} shell COMP_WORDS ( Arrays()) shell DIRSTACK dirs pushd popd DIRSTACK EUID ID shell FUNCNAME shell shell FUNCNAME FUNCNAME GROUPS GROUPS GROUPS HISTCMD HISTCMD HOSTNAME HOSTTYPE bash LINENO shell ( 1 ) LINENO MACHTYPE bash GNU cpu-company-system OLDPWD cd OPTARG getopts ( shell (SHELL BUILTIN COMMANDS) ) OPTIND getopts ( shell (SHELL BUILTIN COMMANDS) ) OSTYPE bash PIPESTATUS ( Arrays )() PPID shell PWD cd RANDOM 0 32767 RANDOM RANDOM REPLY read SECONDS shell SECONDS SECONDS SHELLOPTS shell set -o SHELLOPTS set -o on bash SHLVL bash UID ID shell bash BASH_ENV bash shell shell ~/.bashrc BASH_ENV PATH CDPATH cd shell cd ".:~:/usr". COLUMNS select SIGWINCH COMPREPLY bash shell FCEDIT fc FIGNORE ( READLINE ) ".o:~". GLOBIGNORE GLOBIGNORE HISTCONTROL ignorespace, space ignoredups, ignoreboth HISTIGNORE HISTIGNORE HISTCONTROL HISTFILE ( HISTORY ) ~/.bash_history shell HISTFILESIZE 500 shell HISTIGNORE ( `*') HISTCONTROL shell `&' `&' HISTIGNORE HISTSIZE ( HISTORY ) 500 HOME cd HOSTFILE /etc/hosts shell shell bash HOSTFILE bash /etc/hosts HOSTFILE IFS Internal Field Separator read ``'' IGNOREEOF shell EOF EOF bash 10 EOF INPUTRC readline ~/.inputrc ( READLINE ) LANG LC_ LC_ALL LANG LC_ LC_COLLATE LC_CTYPE LC_MESSAGES $ LC_NUMERIC LINES select SIGWINCH MAIL MAILPATH bash MAILCHECK bash 60 shell shell MAILPATH `?' $_ MAILPATH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"' Bash (/var/mail/$USER) OPTERR 1 bash getopts ( shell (SHELL BUILTIN COMMANDS) ) shell shell OPTERR 1 PATH shell ( (COMMAND EXECUTION) ) bash ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.'' POSIXLY_CORRECT bash posix mode --posix shell bash posix mode set -o posix PROMPT_COMMAND PS1 ( PROMPTING ) ``\s-\v\$ '' PS2 PS1 ``> '' PS3 select ( SHELL GRAMMAR ) PS4 PS1 bash PS4 indirection ``+ '' TIMEFORMAT time % %% % %[p][l]R %[p][l]U CPU %[p][l]S CPU %P CPU (%U + %S) / %R p () 0 p 3 3 p 3 l MMmSS.FFs p bash $'\nreal\t%3lR\nuser\t%3lU\nsys%3lS' TMOUT 0 TMOUT read TMOUT select shell Bash auto_resume shell name exact substring substring %? ( JOB CONTROL ) % histchars (tokenization HISTORY EXPANSION ) history expansion() `!' quick substitution() `^' `#' shell Arrays Bash declare 0 name[subscript]=value subscript 0 declare -a name ( shell (SHELL BUILTIN COMMANDS) ) declare -a name[subscript] subscript declare readonly name=(value1 ... valuen) value [subscript]=stringstring 0 declare name[subscript]=value ${name[subscript]} subscript @ * name ${name[*]} IFS ${name[@]} name ${name[@]} * @ ( Special Parameters )${#name[subscript]} ${name[subscript]} subscript * @ 0 unset unset name[subscript] subscript unset name, name unset name[subscript], subscript * @ declare, local, readonly -a read -a set declare (EXPANSION) brace expansion(), tilde expansion(), parameter and variable expansion(), command substitution(), arithmetic expansion(), word splitting(), pathname expansion(). brace expansion, tilde expansion, parameter, variable arithmetic expansion command substitution (), word splitting, pathname expansion. process subtitution () brace expansion, word splitting, pathname expansion "$@" "${name[@]}" ( PARAMETERS) Brace Expansion Brace expansion pathname expansion, preamble(), postscript() 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} bash file1 file2 . sh bash +B set +B ( shell (SHELL BUILTIN COMMANDS) ) Tilde Expansion (`~') (`/') ( ) tilde- prefix() tilde-prefix login name() shell HOME HOME shell tilde-prefix tilde-prefix `~+' shell PWD tilde-prefix `~-' shell OLDPWD, tilde- prefix N `+' `-' tilde-prefix tilde-prefix dirs tilde- prefix `+' : = tilde-prefix PATH, MAILPATH, CDPATH shell Parameter Expansion `$' `}' ${parameter} parameter parameter parameter parameter bash parameter parameter indirect expansion(). ${!prefix*} word bash ${parameter:-word} Use Default Values() parameter word parameter ${parameter:=word} Assign Default Values() parameter word parameter. parameter ${parameter:?word} Display Error if Null or Unset() parameter word ( word ) shell parameter ${parameter:+word} Use Alternate Value() parameter word ${parameter:offset} ${parameter:offset:length} Substring Expansion() parameter length offset length parameter offset length offset ( ARITHMETIC EVALUATION ) length 0 offset 0 parameter parameter @ length offset parameter @ * length ${parameter[offset]} 0 1 ${!prefix*} prefix IFS ${#parameter} parameter () parameter * @, parameter * @, ${parameter#word} ${parameter##word} word parameter parameter (``#'' ) (``##'') parameter @ *, parameter @ *, ${parameter%word} ${parameter%%word} word parameter parameter (``%'' ) (``%%'') parameter @ *, parameter @ *, ${parameter/pattern/string} ${parameter//pattern/string} patterm parameter pattern string pattern string pattern # parameter pattern % parameter string pattern pattern / parameter @ *, parameter @ *, Command Substitution (Command substitution) $(command) `command` Bash command $(cat file) $(< file) ("``") $, `, \. $(command) Arithmetic Expansion $((expression)) expression (ARITHMETIC EVALUATION) expression bash Process Substitution Process substitution () (FIFOs) /dev/fd <(list) >(list) list FIFO /dev/fd >(list) list <(list) list Word Splitting shell word splitting() shell IFS IFS , IFS IFS space tab IFS ( IFS ) IFS IFS IFS IFS IFS ("" '') Pathname Expansion -f bash *, ?, [. pattern() shell nullglob nullglob nocaseglob ``.'' dotglob shell ``.'' shell (SHELL BUILTIN COMMANDS) shopt shell nocaseglob, nullglob, dotglob GLOBIGNORE pattern GLOBIGNORE GLOBIGNORE ``.'' ``..'' GLOBIGNORE GLOBIGNORE shell dotglob ``.'' ( ``.'' ) ``.*'' GLOBIGNORE dotglob GLOBIGNORE Pattern Matching NUL * ? [...] (`-') range expression () [ ! ^ LC_COLLATE () - ] [ ] character classes () [:class:] class POSIX.2 : alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit word _ [ ] [=c=] equivalence class () c (collation weight ) [ ] [.symbol.] (collating symbol) symbol shopt shell extglob pattern- list | ?(pattern-list) *(pattern-list) +(pattern-list) @(pattern-list) !(pattern-list) Quote Removal \, ', " (REDIRECTION) redirected () shell shell simple command () command <, ( 0) >, ( 1) brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, pathname expansion, word splitting 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 Internet port bash socket () TCP /dev/udp/host/port host Internet port bash socket () UDP Redirecting Input word n n ( 0) [n] word n n ( 1) [n]>word > set noclobber word >|, > set noclobber word Appending Redirected Output () word n n ( 1) [n]>>word Redirecting Standard Output and Standard Error Bash ( 1 2) word / &>word >&word >word 2>&1 Here Documents shell word (trailing blanks) here-document <<[-]word here-document delimiter word parameter expansion, command substitution, arithmetic expansion, pathname expansion word delimiter word here-document word here- documnet parameter expansion, command substitution, arithmetic expansion \ \ \, $, `. <<-, tab delimiter shell here-document Here Strings here-document << Duplicating File Descriptors () [n]<&word word n word word -, n n ( 0) [n]>&word n ( 1) word n word Moving File Descriptors [n]<&digit- digit n, ( 0) n digit n [n]>&digit- digit n, ( 1) n Opening File Descriptors for Reading and Writing [n]<>word word n n 0 (ALIASES) Aliases () shell alias unalias ( shell (SHELL BUILTIN COMMANDS) ) shell metacharacters () = ls ls -F bash blank, alias unalias shell ( FUNCTIONS () ) shell shopt expand_aliases Bash alias shell (be superseded) (FUNCTIONS) shell SHELL GRAMMAR shell shell ( shell ) (positional parameters) # 0 FUNCNAME shell DEBUG ( trap shell (SHELL BUILTIN COMMANDS) ) trace ( declare ) local return # declare typeset -f declare typeset -F export -f shell ("ARITHMETIC EVALUATION") shell ( let Arithmetic Expansion ()) C id++ id-- / () ++id --id / () - + () / ! ~ ** * / % + - << >> / <= >= < > == != / & (AND) ^ (exclusive OR) | (OR) && (AND) || (OR) expr?expr:expr = *= /= %= += -= <<= >>= &= ^= |= expr1 , expr2 shell shell shell 0 0x 0X [base#]n base 2 64 n base# 10 10 @ _ base 36 10 35 ("CONDITIONAL EXPRESSIONS") [[ test [ file /dev/fd/n n file /dev/stdin /dev/stdout /dev/stderr 01 2 -a file file -b file file -c file file -d file file -e file file -f file file -g file file ID (sgid) -h file file -k file file ``sticky'' () -p file file (FIFO) -r file file -s file file -t fd fd -u file file ID (suid) -w file file -x file file -O file file ID -G file file ID -L file file -S file file -N file file file1 -nt file2 file1 file2 () file1 file2 file1 -ot file2 file1 file2 file1 file2 file1 -ef file2 file1 file2 inode -o optname shell optname set -o -z string string 0 -n string string string 0 string1 == string2 = == POSIX string1 != string2 string1 < string2 string1 string2 string1 > string2 string1 string2 arg1 OP arg2 OP -eq, -ne, -lt, -le, -gt, -ge arg1 arg2 Arg1 arg2 / ("SIMPLE COMMAND EXPANSION") shell 1. () 2. 3. REDIRECTION 4. = shell shell shell (COMMAND EXECUTION) shell shell FUNCTIONS shell shell bash PATH () Bash ( shell (SHELL BUILTIN COMMANDS) hash PATH shell 127 shell 0 shell script () shell (spawn) shell shell shell shell ( shell (SHELL BUILTIN COMMANDS) hash) #! shell (COMMAND EXECUTION ENVIRONMENT) shell execution environment () o shell exec o cdpushd popd shell o umask shell o trap o shell set o shell o () set o shopt o alias shell o $$ $PPID shell shell o shell o o o (export) shell o shell shell shell shell shell shell shell shell shell shell shell shell & /dev/null shell (ENVIRONMENT) environment - (name-value) name=value. shell shell export () export declare -x shell () unset export declare -x simple command PARAMETERS set -k bash _ ("EXIT STATUS") shell 0 0 fatal signal N bash 128+N 127 126 shell 0(true) (false) 2 Bash exit (SIGNALS) bash SIGTERM ( kill 0 shell) SIGINT ( wait ) bash SIGQUIT bash SIGTTIN, SIGTTOU, SIGTSTP. bash shell SIGINT SIGQUIT SIGTTIN, SIGTTOU, SIGTSTP. SIGHUP shell shell SIGHUP shell SIGCONT SIGHUP. shell disown ( shell (SHELL BUILTIN COMMANDS) ) disown -h SIGHUP shopt shell huponexit shell bash SIGHUP bash (trap) bash wait wait 128 ("JOB CONTROL") Job control () (suspend) (resume) bash shell (job) jobs bash (background) [1] 25647 1 ID 15647 Bash (job) "" (current terminal process group ID) ( ID ID ) SIGINT. foreground() Background () ID / SIGTTIN (SIGTTOU) bash bash suspend ( ^Z, Control-Z) bash. delayed suspend , ( ^Y, Control-Y) bash. bg fg kill ^Z (pending) shell % n %n %ce ce bash %?ce, ce bash %% %+ shell current job previous job %- ( jobs ) +, -. %1 ``fg %1'' 1 ``%1 &'' 1 ``bg %1'' shell bash set -b bash SIGCHLD bash shell jobs shell (PROMPTING) bash PS1 PS2 Bash \a ASCII (07) \d " " ("Tue May 26") \D{format} format strftime(3) format \e ASCII (033) \h `.' \H \j shell \l shell \n \r \s shell $0 () \t 24 HH:MM:SS \T 12 HH:MM:SS \@ 12/ (am/pm) \A 24/ \u the username of the current user \v bash (2.00) \V bash (2.00.0) \w \W \! \# \$ UID 0 #, $ \nnn nnn \\ \[ \] ( HISTORY ) shell parameter expansion, command substitution, arithmetic expansion quote removal, shell promptvars ( shell (SHELL BUILTIN COMMANDS) shopt ) readline(READLINE) shell shell --noediting emacs vi shell set +o emacs +o vi ( shell (SHELL BUILTIN COMMANDS) ) Readline Notation emacs Ctrl C-key C-n Ctrl-N meta M-key M-x Meta-x( meta M-x ESC-x Esc x Esc meta prefixM-C-x Esc-Ctrl-x Esc Ctrl x ) readline (arguments) (kill-line) (killing) (yanking) kill ring kill ring Readline Initialization readline (inputrc ) INPUTRC ~/.inputrc. readline readline # $ 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 (macro) Readline Key Bindings 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- Ctrl \M- Meta \e Esc \\ \" " \' ' GNU Emacs \a \b \d \f \n \r \t \v \nnn nnn () \xHH HH () " ' Bash bind readline set -o ( shell (SHELL BUILTIN COMMANDS) ) Readline Variables readline inputrc set variable-name value readline On Off bell-style (audible) readline none readline visiblereadline audiblereadline comment-begin (``#'') readline insert-comment emacs M-# vi # completion-ignore-case (Off) Onreadline completion-query-items (100) possible-completions 0 convert-meta (On) Onreadline ASCII ( Esc meta prefix) disable-completion (Off) Onreadline self-insert editing-mode (emacs) readline emacs vi editing-mode emacs vi enable-keypad (Off) On readline expand-tilde (Off) Onreadline history-preserve-point On previous-history next-history horizontal-scroll-mode (Off) On readline input-meta (Off) Onreadline () 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 (*) mark-symlinked-directories (Off) On ( mark-directories ) match-hidden-files (On) On readline `.' () `.' output-meta (Off) Onreadline meta page-completions (On) Onreadline more print-completions-horizontally (Off) Onreadline show-all-if-ambiguous (Off) on, visible-stats (Off) On stat(2) Readline Conditional Constructs readline C $if $if readline mode $if mode= readline emacs vi set keymap emacs-standard emacs-ctlx readline emacs term term= = - sun sun sun-cmd application application readline application name bash $if Bash # Quote the current or previous word "\C-xq": "\eb\"\ef\"" $endif $endif $if $else $if $include /etc/inputrc $include /etc/inputrc Searching readline ( HISTORY ) incremental non-incremental. readline isearch-terminators Esc Ctrl-J Ctrl-G Ctrl-S Ctrl-R / readline newline readline Ctrl-R Readline Command Names (point) (mark) set-mark point mark (region) Commands for Moving 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 Commands for Manipulating the History 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 point history-search-backward point yank-nth-arg (M-C-y) () point n n ( 0 ) point n yank-last-arg (M-., M-_) () yank-nth-arg yank-last-arg shell-expand-line (M-C-e) shell shell 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 operate-and-get-next (C-o) edit-and-execute-command (C-xC-e) shell Bash $FCEDIT, $EDITOR, emacs Commands for Changing Text delete-char (C-d) point point 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) point point point point point transpose-words (M-t) point point point point upcase-word (M-u) () point downcase-word (M-l) () point capitalize-word (M-c) () point overwrite-mode / emacs vi readline() self-insert point backward-delete-char point Killing and Yanking kill-line (C-k) point backward-kill-line (C-x Rubout) unix-line-discard (C-u) backward-kill-line kill-ring kill-whole-line point kill-word (M-d) point point backward-kill-word (M-Rubout) point backward-word unix-word-rubout (C-w) point kill-ring delete-horizontal-space (M-\) point kill-region region copy-region-as-kill region copy-backward-word point backward-word copy-forward-word point backward-word yank (C-y) kill-ring point yank-pop (M-y) kill-ring yank yank-pop Numeric Arguments digit-argument (M-0, M-1, ..., M--) (already accumulating) M-- universal-argument universal-argument 4 1 4 16 Completing complete (TAB) point Bash ( $ ) ( ~ ) ( @ ) () possible-completions (M-?) point insert-completions (M-*) possible-completions point menu-complete complete menu-complete ( bell-style ) n n TAB delete-char-or-list ( delete-char) possible-completions complete-filename (M-/) point possible-filename-completions (C-x /) point complete-username (M-~) point possible-username-completions (C-x ~) point complete-variable (M-$) point shell possible-variable-completions (C-x $) point shell complete-hostname (M-@) point possible-hostname-completions (C-x @) point complete-command (M-!) point shell shell possible-command-completions (C-x !) point dynamic-complete-history (M-TAB) point complete-into-braces (M-{) shell ( Brace Expansion ) Keyboard Macros start-kbd-macro (C-x () end-kbd-macro (C-x )) call-last-kbd-macro (C-x e) Miscellaneous re-read-init-file (C-x C-r) inputrc abort (C-g) ( bell-style ) do-uppercase-version (M-a, M-b, M-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-&) set-mark (C-@, M-) point mark exchange-point-and-mark (C-x C-x) point mark mark character-search (C-]) point character-search-backward (M-C-]) point insert-comment (M-#) readline comment-begin comment-begin comment-begin comment-begin shell shell glob-complete-word (M-g) point glob-expand-word (C-x *) point glob-list-expansions (C-x g) glob-expand-word dump-functions readline inputrc dump-variables readline readline inputrc dump-macros readline readline inputrc display-shell-version (C-x C-v) bash Programmable Completion complete ( compspec) ( shell (SHELL BUILTIN COMMANDS) ) Completing bash -f -d shell FIGNORE -G shell GLOBIGNORE FIGNORE -W IFS shell EXPANSION brace expansion, tilde expansion, parameter variable expansion, command substitution, arithmetic expansion, pathname expansion Word Splitting -F -C shell COMP_LINE COMP_POINT Shell Variables shell COMP_WORDS COMP_CWORD -F shell compgen COMPREPLY -C -X & & ! B-P -S readline compspec complete -o dirname bash readline complete -o default readline readline readline mark-directories readline mark-symlinked-directories (HISTORY) set -o history shell command history HISTSIZE HISTSIZE (500) shell ( EXPANSION ) shell HISTIGNORE HISTCONTROL HISTFILE ( ~/.bash_history) HISTFILE HISTFILESIZE shell $HISTSIZE $HISTFILE shell histappend ( shell (SHELL BUILTIN COMMANDS) shopt ) HISTFILE HISTFILESIZE HISTFILESIZE fc ( shell (SHELL BUILTIN COMMANDS) ) history shell HISTCONTROL HISTIGNORE shell shell cmdhist shell shell lithist shell shell (SHELL BUILTIN COMMANDS) shopt shell ("HISTORY EXPANSION") shell csh shell set -H ( shell (SHELL BUILTIN COMMANDS) ) shell shell event words modifiers metacharacter ! (\) shopt shell histverify ( shopt ) readline shell readline readline shell histreedit readline history -p history -s shell ( Shell Variables histchars ) Event Designators (event designator) ! blank, newline, = (. !n n. !-n n. !! `!-1' !string string !?string[?] string ? string ^string1^string2^ string1 string2. ``!!:s/string1/string2/'' ( (Modifiers)) !# Word Designators (word designator) event : event word ^, $, *, -, % 0 0 (zero) 0 shell n n ^ 1 $ % `?string?' x-y `-y' `0-y' * 0 `1-$' event * x* x-$ x- -$ x* word event event (Modifiers) word modifiers `:' h t r .xxx e p q x q, blanks s/old/new/ old new / old new & new old & old old !?string[?] string & g `:s' `:&' (`:gs/old/new/') `:s' / shell (SHELL BUILTIN COMMANDS) - -- : [arguments] arguments 0 . filename [arguments] source filename [arguments] shell filename filename filename (slash) PATH filename PATH bash posix mode PATH shopt sourcepath PATH arguments filename (positional parameters) 0 filename false alias [-p] [name[=value] ...] Alias -p alias name=value value name value name value Alias true name bg [jobspec] jobspec & jobspecshell current job bg jobspec 0 jobspec bind [-m keymap] [-lpsvPSV] 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 readline-command readline readline readline .inputrc '"\C-x\C-r": re-read-init-file' -m keymap keymap keymap keymap emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, 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 filename filename -q function function -u function function -r keyseq keyseq -x keyseq:shell-command shell-command keyseq 0 break [n] for, while, until, select n n n >= 1 n 0 break shell builtin shell-builtin [arguments] shell arguments shell cd false shell-builtin shell cd [-L|-P] [dir] dir HOME CDPATH dir CDPATH (:) CDPATH ``.''. (/,slash) CDPATH -P ( set -P ); -L - $OLDPWD true false command [-pVv] command [arg ...] command args shell PATH -p command PATH -V -v command -v command -V -V -v command 01 command 127 command command compgen [option] [word] option word option complete -p -r -F -C shell word word complete [-abcdefgjksuv] [-o comp-option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] name [name ...] complete -pr [name ...] name -p -r name name Programmable Completion() -G, -W, -X ( -P -S ) complete -o comp-option comp-option compspec comp-option default readline compspec dirnames compspec filenames readlinecompspec () shell nospace readline () -A action action alias -a arrayvar binding Readline builtin shell -b command -c directory -d disabled enabled export shell -e file -f function shell group -g helptopic help hostname HOSTFILE job -j keyword shell -k running service -s setopt set -o shopt shopt shell signal stopped user -u variable shell -v -G globpat globpat -W wordlist wordlist IFS -C command command shell -F function shell function shell COMPREPLY -X filterpat filterpat filterpat filterpat ! filterpat -P prefix prefix -S suffix suffix -p -r name name continue [n] for, while, until, select n n n >= 1 n (``top-level'' loop) 0 continue shell declare [-afFirtx] [-p] [name[=value]] typeset [-afFirtx] [-p] [name[=value]] / name -p name -p -F -F -f. -a name ( Arrays ) -f -i ( (ARITHMETIC EVALUATION) ) -r name -t name trace() shell DEBUG trace -x name `+' `-' +a name local 0 ``-f foo=bar'' ( Arrays )name shell -f dirs [-clpv] [+n] [-n] pushd popd +n dirs n 0 -n dirs n 0 -c -l -p -v 0 n disown [-ar] [-h] [jobspec ...] jobspec - jobspec shell SIGHUP SIGHUP jobspec -a -r (current job) jobspec -a -r jobspec 0 jobspec echo [-neE] [arg ...] arg 0 -n -e -E shell xpg_echo echo echo -- echo \a alert (bell) \b backspace \c suppress trailing newline \e an escape character Esc \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \\ backslash \0nnn nnn () \nnn nnn () \xHH HH () enable [-adnps] [-f filename] [name ...] shell shell -n name name PATH test shell ``enable -n test''. -f filename name -d -f name -p shell shell -n -a -s POSIX special 0 name shell eval [arg ...] arg shell eval args eval 0 exec [-cl] [-a name] [command [arguments]] command shell arguments command -l shell command 0 (dash,`-') login(1) -c command -a shell name 0 as the zeroth argument to the executed command. If command shell shell execfail shell command shell 0 1 exit [n] shell n n shell EXIT export [-fn] [name[=word]] ... export -p names -f names names -p shell -n export 0name shell -f name fc [-e ename] [-nlr] [first] [last] fc -s [pat=rep] [cmd] first last First last () ( ) last ( ``fc -l -10'' 10 ) first first -16 -n -r -l ename ename FCEDIT FCEDIT EDITOR vi command pat rep ``r=fc -s'', ``r cc'' ``cc'' ``r'' 0 first last -e cmd fc fg [jobspec] jobspec jobspec shell current job jobspec jobspec getopts optstring name [args] getopts shell optstring getopts shell name name OPTIND shell shell OPTIND 1 getopts OPTARG shell OPTIND shell getopts getopts 0 OPTIND name ? getopts args getopts getopts optstring silent OPTERR 0 optstring getopts name ? OPTARG getopts OPTARG getopts name (?) OPTARG getopts name (:) OPTARG getopts / hash [-lr] [-p filename] [-dt] [name] name, $PATH -p filename -r shell -d shell name -t name name -t name -l -l name help [-s] [pattern] pattern () help pattern shell -s 0 pattern history [n] history -c history -d offset history -anrw [filename] history -p arg [arg ...] history -s arg [arg ...] * n n filename HISTFILE -c -d offset offset -a ``'' ( bash ) -n bash -r -w -p args args -s args args 0/ -d offset -p jobs [-lnprs] [ jobspec ... ] jobs -x command [ args ... ] -l ID -p leader ID -n -r -s jobspec 0 jobspec -x jobs command args jobspec ID command args kill [-s sigspec | -n signum | -sigspec] [pid | jobspec] ... kill -l [sigspec | exit_status] pid jobspec sigspec signum sigspec SIGKILL signum sigspec SIG sigspec SIGTERM -l -l 0 -l exit_status kill let arg [arg ...] arg ( (ARITHMETIC EVALUATION) ) arg 0 let 1 0 local [option] [name[=value] ...] name value option declare local name local local 0 local name name logout shell popd [-n] [+n] [-n] cd +n dirs n ( 0 ) ``popd +0'' ``popd +1'' -n dirs n ( 0 ) ``popd -0'' ``popd -1'' -n popd dirs 0 popd printf format [arguments] format arguments format argument printf(1) %b printf arguments %q printf argument shell format arguments format arguments 0 0 0 pushd [-n] [dir] pushd [-n] [+n] [-n] 0 +n dirs n ( 0 ) -n dirs n ( 0 ) -n dir dir pushd dirs pushd 0 cd dir pushd 0 pwd [-LP] -P set -o physical -L 0 read [-ers] [-u fd] [-t timeout] [-a aname] [-p prompt] [-n nchars] [-d delim] [name ...] -u fd name, name, name. IFS (\) -a aname aname 0 aname name -d delim delim -e readline ( READLINE ) -n nchars read nchars -p prompt prompt -r - -s -t timeout read timeout read -u fd fd names REPLY 0 EOFreadP -u readonly [-apf] [name ...] name names -f names -a name -p -p 0 names shell -f name return [n] n n . (source) shell n . set [--abefhkmnptuvxBCHP] [-o option] [arg ...] shell shell $1, $2, ... $n. -a -b -e simple command ( SHELL GRAMMAR ) shell until while if && || ! ERR shell -f -h -k -m shell ( JOB CONTROL ) -n shell shell -o option-name option-name allexport -a braceexpand -B emacs emacs shell shell --noediting errexit -e hashall -h histexpand -H history HISTORY shell ignoreeof shell ``IGNOREEOF=10'' ( Shell Variables ) keyword -k monitor -m noclobber -C noexec -n noglob -f nolog notify -b nounset -u onecmd -t physical -P posix POSIX 1003.2 bash (posix mode) privileged -p verbose -v vi vi xtrace -x option-name -o option-name +o set -p privileged mode () $ENV $BASH_ENV shell SHELLOPTS shell () ID () ID -p ID ID -p ID ID ID -t -u shell ; shellshell -v -x PS4 -B shell ( Brace Expansion) -C bash >, >&, <> >| > -H Enable ! shell -P shell cd bash -- arg - - arg -x -v arg + - shell $- shift [n] n+1 ... $1 .... $# $#-n+1 n $# n 0 n 1 n $# 0 n $# 0 0 shopt [-pqsu] [-o] [optname ...] shell -p -p -s () optname -u () optname -q () optname -q optname optname 0 -o optname set -o -s -u optname shopt () 0 optname 0 optname shell shopt cdable_vars cd cdspell cd shell checkhash bash checkwinsize bash LINES COLUMNS cmdhist bash dotglob bash `.' execfail shell exec shell exec expand_aliases ALIASES shell extglob Pathname Expansion histappend shell HISTFILE histreedit readline histverify readline shell readline hostcomplete readline bash ( READLINE Completing ) huponexit shell bash SIGHUP interactive_comments shell # ( COMMENTS ) lithist cmdhist login_shell shell shell ( (INVOCATION) ) mailwarn bash ``The mail in mailfile has been read''(mailfile ) no_empty_cmd_completion readline bash PATH nocaseglob bash ( Pathname Expansion ) nullglob bash ( Pathname Expansion ) progcomp ( Programmable Completion) promptvars PROMPTING restricted_shell shell ( shell(RESTRICTED SHELL) ) shell shift_verbose shift sourcepath source (.) PATH xpg_echo echo suspend [-f] shell SIGCONT -f shell 0 shell shell -f test expr [ expr ] 0 1 expr (CONDITIONAL EXPRESSIONS) ! expr expr ( expr ) expr expr1 -a expr2 expr1 expr2 expr1 -o expr2 expr1 expr2 test [ 0 arguments 1 argument 2 arguments ! (CONDITIONAL EXPRESSIONS) 3 arguments (CONDITIONAL EXPRESSIONS) ! ( ) -a -o 4 arguments ! 5 arguments times shell shell 0 trap [-lp] [arg] [sigspec ...] shell sigspec arg arg -, ( shell ) arg sigspec shell arg -p sigspec -p trap sigspec sigspec EXIT (0) arg shell sigspec DEBUG, arg (simple command SHELL GRAMMAR) sigspec ERR, arg until while if && || ! ERR -l shell shell sigspec trap type [-aftpP] name [name ...] name -t type alias, keyword, function, builtin, file name shell name -p type name ``type -t name'' file. -P name PATH ``type -t name'' file. -p -P PATH -a type name -p -a -f shell command type ulimit [-SHacdflmnpstuv [limit]] shell -H -S -H -S limit hard, soft, unlimited limit -H -a -c core -d -f shell -l -m -n () -p 512 () -s -t cpu -u -v shell limit ( -a ) -f 1024 -t -p 512 -n -u 0 umask [-p] [-S] [mode] mode. mode chmod(1) mode -S -p mode 0 mode unalias [-a] [name ...] name -a name unset [-fv] [name ...] name -v name shell -f name shell RANDOM, SECONDS, LINENO, HISTCMD, FUNCNAME, GROUPS, DIRSTACK name wait [n] n ID n 0 n 127 shell(RESTRICTED SHELL) bash rbash -r shell shell shell bash (disallowed) (not performed) o cd o SHELL, PATH, ENV, BASH_ENV o / o / . o (slash) -p hash o shell (import) o shell SHELLOPTS o >, >|, <>, >&, &>, >> o exec shell o enable -f -d o enable shell o command -p o set +r set +o restricted shell ( (COMMAND EXECUTION) ) rbash (spawn) shell ("SEE ALSO") 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) (FILES) /bin/bash bash /etc/profile shell ~/.bash_profile shell ~/.bashrc shell ~/.bash_logout shell shell ~/.inputrc readline (AUTHORS) Brian Fox, Free Software Foundation bfox@gnu.org Chet Ramey, Case Western Reserve University chet@ins.CWRU.Edu BUGS (BUG REPORTS) bash bug bug bash bug bashbug bash "" (`philosophical') "" bug-bash@gnu.org Usenet gnu.bash.bug bash bug bug "" (recipe) bashbug chet@ins.CWRU.Edu. BUGS bash sh POSIX Shell / `a ; b ; c' shell shell $(...) (export) [] [] 2004.03.05 linuxman: http://cmpp.linuxforum.net man man https://github.com/man-pages-zh/manpages- zh GNU Bash-2.05b 2002 July 15 BASH(1)