BA SH REFERENCE
A liasing...6
A rithmetic Evaluation... 8
A rrays ...13 BraceExpansion... 6
Built-In Commands ... 16 Command Line A rguments ... 3
Command Substitution... 8
Conditional Expressions ... 15 Control Commands ... 14 Definitions ...2
Execution Order... 13 Field Splitting... 8
Functions ...12 H istorySubstitution... 5
Input/Output ...13 Invocation and Startup ...3
Job Ids and Job Control... 24
Options Toset... 22
Options Tos hopt... 23
Options Totest... 21
Patterns ...9
Pre-Defined Variables ...10 Process Substitution ... 8
Prompting...4
Quoting...6
Readline ...25
Readline Directives ... 25
Readline KeyBindings ... 25
Readline Variables ...26
Restrictedbash... 2
Signals and Traps ...13 SpecialCharacters... 24
Tilde Substitution... 6
VariableAssignment... 9
Variable Names ... 9
VariableSubstitution ... 7
CONTEN TS
This reference card w as w ritten byA rnold Robbins.W e thankChet Ramey(bash’s maintainer)for his help.
Speci
a
l
i
zedSy
stems Cons ulta
nts,
I
nc.
(
20
6)FOR-
UNI
X/
(
20
6)
7
82-
7
7
33
FAX:
(
20
6)
7
82-
7
1
9
1
E-
ma
i
l
:
sa
l
e
s@ ssc.
com
URL:
h
t
t
p:
/
/
w w w.
ssc.
com
Li
nux
Jour
na
l
—Th
e
Pre
mi
e
r
Li
nux Ma
g
a
zine
Techni
ca
l
Book
s a
nd
CDs
SA MBA :
I
nteg
r
a
ting UNIX a
nd
W i
ndow s
Sh
ell
Tutor
ia
l
s,
KSH
Ref
erence
VI
&
Emacs
Ref
erences,
VI
Tutor
ia
l
OTHER S S C PRODUCTS:
© Copyright 1999Specialized Systems Cons ultants,Inc., P.O.Box55549,Seattle,W A 98155-0549.
A llRights Reserved. 1
This card describes version 2.02.0ofbash. Several typefaces are used to clarifythe meaning: •SerifaBoldis used for computerinput.
•SerifaItalicis used to indicateuser input and for syntactic placeholders,suchasvariableorcmd. • SerifaRoman is used for explanatorytext. blank
or morespaces and/ortab characters.In addition, w ords areterminated by any ofthe follow ing characters:
;&()|<>space tab new line command w ords.
list pipelines.Can be separated by;,&, &&,||and optionallybe terminated by;,&.
n
name
keyw ord bashlanguage. Keyw ords are specialonlyaftera;or new line,after another keyw ord,and in certain other contexts. pat bashpattern.SeePatterns.
pipeline byapipe (|). string
substitution
command line w ith different text,e.g.,replacing a variable w ith its value.bash performs many s ubstitutions.This card lists them in theordertheyare performed.
w ord
necessaryifit contains special characters.
DEFI
NI
TI
ONS
Ifbashis invoked asrbash,orw ith the option,it is restricted.Thefollow ingactions are not allow ed in a restricted shell:
changingdirectoryw ithcd
settingor unsetting$SH ELLor$PATH
usingpathnames for commands that contain/ usingapath namethat contains/for the.command importingfunctions from the environment
parsing$SH ELLOPTSat startup
redirectingoutput w ithanyof>,>|,<>,>&,&>,or>> usingexecto run adifferent command
addingor deleting built-in commands w ithenable using to bypass arestricted$PATH usingset +rorset +o restricted
These restrictions are in effectafterexecuting all startupfiles,allow ingtheauthorofthe startup files full controlin s etting up the restricted environment.(In practice,restricted shells are not used much,as they are difficult to set up correctly.)
RESTRI
CTED
ba
sh
Ifyou find an error in this referenceand arethefirst to report it,w ew illsend you afreecopyofanyofour references.Please w rite, or s end electronic mail to [email protected].
Er
r
or
Repor
ti
ng
2
bashaccepts theone letter options toset,and the additional oneletter and G N U-stylelongoptions show n below .
$bash[options][args]
ends option processing ends option processing cmd execute cmd (default reads
command from filenamed in first entryofargsand found via paths earch)
print alldouble quotedstrings that are preceded by a$to stdout.This implies ,no commands areexecuted set interactive mode set restricted mode
read commands from stdin (default)
sameas ,but output in G N U gettextformat
sameas
dis playahelp messageand exit successfully
act likea login s hell
do not us ethereadlinelibrary to read commands w hen interactive
do not read any of the initialization files. See
Invocation And Startup,below do not read ˜/.bashrc if interactive.SeeInvocation And Startup,below
follow the IEEE POSIX 1003.2 standard
file usefileins tead of˜/.bashrcif interactive
sameas sameas
print version information on stdoutand exit successfully
COMMA ND
LI
NE A RGUMEN TS
Therearefivew ays thatbashruns:normalinteractive, normal non-interactive, as sh,in POSIX mode, or invoked viarshd.
1.Normalinteractive:Login s hells run commands in /etc/profile.The first of˜/.bash_profile,˜/.bash_login, and˜/.profilethat is found is executed.This stageis skipped if is us ed.
Upon logout,bashruns˜/.bash_logoutifit exists. Interactive non-login s hells execute˜/.bashrc,if it exists.The ifileoption changes the filethat is us ed.
2. Normal non-interactive: Non-interactive shells do variable,command,and arithmetic substitution on the valueof$BA SH _ENV,and ifthe result names an existingfile,that fileis executed.
I
NVOCATI
ON A ND S TA RTUP
3
3.Invoked as sh:Interactive login s hells read and execute/etc/profileand˜/.profileiftheyexist.These files are skipped if is us ed.Interactive shells expand$EN V and executethatfileifit exists. Non-interactive shells do not read any startup files. A fterthe startup files are executed,bashenters POSIX mode.
4.POSIX mode:W hen startedw ith ,interactive shells expand$EN V and executethe given file.N o other startup files areread.
5.Invoked viarshd:Ifrun fromrshdand not invoked as sh,bashreads˜/.bashrc.The option skips this step,and the option changes the file,butrshd us uallydoes not pass theseoptions on to the shellit invokes.
If$SH ELLOPTSexists in the environment at startup, bashenables the given options.
I
NVOCATI
ON A ND STA RTUP
(continued)W hen interactive,bashdis plays the primary and secondary prompt strings,$PS1and $PS2.bash expands the follow ingescape sequences in thevalues ofthesestrings.
\a an A SCIIBEL character(octal 07) \d the datein ‘‘W eekdayMonth Day’’format \e an A SCIIescape character(octal 033) \h thehostname up to the first dot (.) \H the fullhostname
\n anew line \r acarriage return
\s the nameofthe shell(basename of$0) \t the timein 24-hourH H :MM:SS format \T the timein 12-hourH H :MM:SS format \u the user’s username
\v theversion ofbash(e.g.,2.02)
\V theversion and patchlevelofbash(e.g.,2.02.0) \w the current w orkingdirectory
\W the basenameofthe current w orkingdirectory \! the historynumberofthis command
\# the command numberofthis command \$ a#iftheeffective UID is 0,otherw isea$ \@ the timein 12-houram/pm format \\ abackslash
\nnn the character correspondingto octal valuennn \[ startasequence ofnon-printingcharacters \] end asequence ofnon-printingcharacters The historynumberis the numberofthe command in the historylist,w hich mayinclude commands restored from the history file.The command numberis the number ofthis command starting from the first command run bythe current invocation ofthe shell. Thedefault value ofPS1is ‘‘ ’’.
PROMPTI
NG
H istoryexpansion is similar tocsh’s.Itis enabled by default in interactive shells. H istory expansion happens beforetheshellbreaks theinput into w ords, although quoting is recognized and quotedtext is treated as onehistory‘‘w ord’’.
H istory s ubstitution is performed on historyevents, w hich cons ist ofanevent designator(w hich previous line to startw ith),aw ord designator(w hich w ord from that line to use,starting w ithzero),and one or more optionalmodifiers (w hich parts ofthe w ords to use). Colons separatethe threeparts,although the colon betw een theevent designator and w ord designator maybe omitted w hen the w ord designator begins w ith ˆ,$,*,,or%.Each modifieris separatedfrom thenext one w ithacolon.Thehistcharsvariablespecifies the start-of-historyand quicksubstitution characters,and also the comment characterthat indicates that the rest ofaline is a comment.The previous command is the default event ifno event designator is supplied. Theevent designators are:
! startahistorys ubstitution !n command linen
n current line minusn(nprevious) !! the previous command
!str most recent command line startingw ith str
!?str[?] most recent command line containingstr !# the entire command line typed so far ˆoldˆnewˆ quicksubstitution:repeatlast command
changingoldtonew The w ord designators are:
0 the zero’th w ord (command name)
n w ordn
ˆ the first argument,i.e.,w ord one $ the last argument
% the w ord matched by the most recent !?str?search
xy w ordsxthroughy. is shortfor * w ords 1throughthelast (like ) n* w ordsnthroughthelast (liken ) n w ordsnthroughthenext to last The modifiers are:
e removeallbut the s uffixofafilename g make changes globally, us e w ith s
modifier,below
h remove the last part of a filename, leavingthe ‘‘head’’
p print the command but do not executeit q quotethegeneratedtext
r removethe last suffixofafilename s/old/new/ s ubstitutenew foroldin the text.A ny
delimiter may be used.A n &in the replacement means thevalue ofold.W ith emptyold,uselastold,orthe most recent !?str?search iftherew as no previousold t removeallbut the last partofafilename,
leavingthe ‘‘tail’’
x quotethegeneratedtext,but breakinto w ords atblanksand new line
& repeat thelast substitution
H I
STORY SUBSTI
TUTI
ON
\c quotesinglecharacterc `...` old s tyle command s ubstitution
"..." text treatedas asingleargument,double quotes removed;variable,command and arithmetic substitutions performed; use\to quote$,\,`,and" $"..." like"...",but localetranslation done ´...´ text treatedas asingleargument,single
quotes removed;text betw een quotes leftalone,cannot include´
$´...´ text treatedas asingleargument,$and single quotes removed;no s ubstitutions performed;A N SIC and additional escape sequences processed: \a alert(bell) \v verticaltab \b backspace \ddd octalvalueddd \f form feed \xhhh hexvaluehhh \n new line \\ backslash
\r carriagereturn \e escape,not in A N SIC \t horizontal tab
QUOTI
NG
aliasname=value...
A liases areexpanded w hen a command is read, not w hen executed.A lias names can contain any non-specialcharacter,not jus t alphanumerics,except for=. A lias expansion is done on the firstw ordofa command. Ifthe last character of thereplacement text is ablank, then thenext w ord in the command line is checked for alias expansion.A liases can even be used to redefine shellkeyw ords ,but not in POSIX mode.
ALI
A SI
NG
Braceexpansion is similar tocsh’s.A w ord must contain at least one unquotedleftbraceand commato be expanded.bashexpands the comma-separated items in order,the result is not sorted.Brace expansions maybe nested.Forexample:
$mkdir /usr/{gnu,local}/{src,bin,lib}
BRA CE EXP
A NSI
ON
˜ s ubstitute$H OME
˜user s ubstituteuser’s home directory ˜+ s ubstitute$PW D
s ubstitute$OLD PW D
˜n s ubstitute${DIRSTA CK[n]}.A leading+ or is allow ed: negative values count from the end ofthe stack
Tilde s ubstitution happens afteralias expansion.It is done forw ords that begin w ith˜and for variable assignment.
In variableassignments,it is also doneaftera:in the value.Tilde s ubstitution is doneas part of w ord expansion.This means for${nameop w ord},w ordw illbe checked for tilde s ubstitution,but onlyiftheoperation requires thevalue ofthe right-hand side.
TI
LDE
SUBSTI
TUTI
ON
$name referenceto shellvariablename ${name} us ebraces to delimit shellvariablename ${name w ord}
us e variablenameifset,elseusew ord ${name=w ord}
as above but also setnametow ord ${name?w ord}
usenameifset,otherw iseprintw ordand exit (interactive shells do not exit) ${name+w ord}
usew ordifnameis set,otherw iseuse nothing
${name[n]} elementnin arrayname ${#name} lengthofshellvariablename ${#name[*]} number of elements in arrayname ${#name[@]} number of elements in arrayname ${name#pat} removeshortest leadings ubstring
ofnamethat matchespat ${name##pat} removelongest leadings ubstring
ofnamethat matchespat ${name%pat} removeshortest trailings ubstring
ofnamethat matchespat ${name%%pat}
removelongest trailings ubstring ofnamethat matchespat ${name:start}
${name:start:length}
lengthcharacters ofnamestartingat start(countingfrom0);us erest of value ifnolength.N egativestart counts from the end.Ifnameis*or@ or an arrayindexed by*or@,start andlengthindicatethearrayindexand count ofelements.startandlengthcan be arithmeticexpressions
${name/pattern/string}
value ofnamew ith first match ofpattern replaced w ithstring
${name/pattern}
value ofnamew ith first match ofpattern deleted
${name//pattern/string}
value ofnamew itheverymatch of patternreplaced w ithstring ${name/#pattern/string}
value ofnamew ith match ofpattern replaced w ithstring;match mus t occur at beginning
${name/%pattern/string}
value ofnamew ith match ofpattern replaced w ithstring;matchoccurs at end Note:for ,=,?,and+,usingname:instead ofname tests w hethernameis set and non-NULL;usingname tests onlyw hethernameis set.
For#,##,%,%%,/,//,/#,and/%,w hennameis*or@ or an array indexed by*or@,the s ubstring or s ubstitution operation is applied to eachelement.
VA RI
A BLE SUBSTI
TUTI
ON
A rithmetic evaluation is done w ith theletbuilt-in command,the ((...)) command and the $((...)) expansion for producingthe result ofan expression. A llarithmetic useslongintegers.Use to get integer variables.Integer constants looklike[base#]n w herebaseis adecimal numberbetw een tw o and 64, andnis in that base.The digits are0-9,a-z,A-Z,_and @.A leading0or0xdenoteoctalor hexadecimal. The follow ing operators based on C, w ith the same precedence and associativity,are available.
unaryplus and minus !˜ logical and bitw isenegation ** exponentiation (not in C) */% multiply,divide,modulus
addition,subtraction << >> left s hift,right shift < <= > >= comparisons == != equals,not equals & bitw iseA N D ˆ bitw iseXOR | bitw iseOR
&& logical A N D,shortcircuit || logical OR,shortcircuit ?: in-line conditional
assignment operators
Insidelet,((...)),and$((...)),variablenames do not need a$to get theirvalues.
A RI
TH METI
C EVALUATI
ON
$(command) new form `command` old form
Runcommand,s ubstitutethe results as arguments. Trailingnew lines are removed. Characters in $IFS separatew ords (seeField Splitting). Thenew form is preferredforsimpler quotingrules.
$((expression))arithmetic substitution
Theexpressionis evaluated,and theresult is used as an argument to thecurrent command.
COMMA ND SUBSTI
TUTI
ON
cmd<(list1)>(list2)
Runs list1andlist2 asynchronous ly,w ithstdin and stdoutrespectivelyconnectedviapipes usingfifos or files in/dev/fd.Thesefile names becomearguments to cmd,w hichexpects to readits first argument and w rite its second.This onlyw orks ifyou have/dev/fdorfifos.
PROCESS SUBSTI
TUTI
ON
Quoted text becomes one w ord. Otherw ise, occurrences ofanycharacterin$IFSseparatew ords. Multiplew hitespacecharacters that arein$IFSdo not delimit emptyw ords, w hile multiple non-w hitespace characters do.W hen$IFSis not the default value, sequences ofleading and trailing$IFS w hitespace characters are removed, and printable characters in $IFS s urrounded by adjacent $IFS w hitespace
? matchsinglecharacterin filename * match0or morecharacters in filename [chars] matchanyofchars
(pairseparatedbya matches arange) [!chars] matchanyexceptchars
[ˆchars] matchanyexceptchars
Iftheextgloboption tos hoptis set,the follow ing extended matchingfacilities maybe used.
?(pat-list) optionallymatchanyofthe patterns *(pat-list) match0or moreofanyofthe patterns +(pat-list) match1or moreofanyofthe patterns @(pat-list) matchexactly1ofanyofthe patterns !(pat-list) matchanything but anyofthe patterns pat-listis alist ofone ormorepatterns separated by|. ThePOSIX [[=c=]]and[[.c.]]notations for same-w eight characters and collatingelements are accepted.The notation[[:class:]]defines characterclasses:
alnum alphanumeric low er low er-case alpha alphabetic print printable blank space ortab punct punctuation cntrl control space w hitespace digit decimal upper upper-case graph non-spaces xdigit hexadecimal Threes hoptoptions affect pattern matching. dotglob includefiles w hosenames begin w ith. nocaseglob ignore casew hen matching
nullglob removepatterns that don’tmatch W hen expanding filenames,.and..are ignored, filenames matchingthe patterns in$G LOBIG N OREare also ignored and a leading.must be s upplied in the pattern to match filenames that begin w ith.. H ow ever,settingG LOBIG N OREenables thedotglob option.Include.*inG LOBIG N OREto get thedefault behavior.
P
ATTERNS
Variablenames are made up ofletters,digits and underscores. Theymaynot startw ithadigit.Thereis no limit on the lengthofavariablename,and the case ofletters is significant.
VA RI
A BLE N A MES
A ssignments to integer variables undergoarithmetic evaluation.Variableassignments have one ofthe follow ingforms.
name=w ord setnametow ord name[index]=w ord
set elementindexofarraynametow ord name=(w ord...)
set indexed arraynametow ords name=([num]=w ord...)
set given indices ofarraynametow ords
VA RI
A BLE ASSI
G N MEN T
9
$n use positional parametern,n 9 ${n} use positional parametern $* allpositionalparameters $@ allpositionalparameters "$*" equivalent to"$1$2..." "$@" equivalent to"$1""$2"... $# number of positional parameters
options to shellor byset $? value returned bylast command $$ process number of current shell $! process number oflast background
cmd
$_ nameof program in environment at startup. Value oflast positional argument in last command.Name of changed mailfilein$MA ILPATH $auto_resume enables use of single-w ord
commands to matchs topped jobs for foregrounding. W ithavalue ofexact, the w ord must exactlymatch the command used to startthe job.W ith avalue ofs ubstring,the typed w ord can beas ubstringofthe command, like%?string
$BA SH fullfilename used to invokebash $BA SH _ENV in normal non-interactive shells only,
value is variable,command and arithmetic substituted for path of startup file (See Invocation And Startup)
$BA SH _VERSION theversion ofbash $BA SH _VERSINFO[0] the major version number
(release)
$BA SH _VERSINFO[1] the minor version number (version)
$BA SH _VERSINFO[2] the patchlevel $BA SH _VERSINFO[3] the build version $BA SH _VERSINFO[4] the releasestatus $BA SH _VERSINFO[5] sameas$MA CH TYPE $CDPATH search path forcdcommand $DIRSTA CK[*] array variable containing thepus hd
andpopddirectorystack
$EN V in interactive POSIX mode shells,or w hen invoked assh,value is variable, command andarithmetic substituted for pathofstartup file
$EUID theeffective us erid (readonly) $FCED IT default editorforthefccommand (no
default value)
$FIG N ORE colon-separatedlist ofs uffixes giving the set offilenames to ignorew hen doing filename completion using readline
$G LOBIG N ORE colon-separatedlist ofpatterns giving the set offilenames to ignorew hen doingpattern matching
$G ROUPS[*] readonlyarrayvariablew ith the list ofgroups theuser belongs to $histchars characters that control csh-style
history (default:!ˆ#).SeeH istory Substitution
PRE-
DEFI
N ED
VA RI
A BLES
10
$H ISTCMD history number of the current command
$H ISTCONTROLw ithavalue ofignorespace,do not enter lines that begin w iths paces into the historyfile.W ithavalue of ignoredups,do not entera line that matches the previous line. Use ignorebothto combine bothoptions $H ISTFILE w here command historyis stored $H ISTFILESIZEmaximum numberoflines to keep in
$H ISTFILE
$H ISTIG N ORE colon-separated list ofpatterns;ifthe current line matches anyofthem,the line is not enteredin the historyfile. &represents the last history line. Patterns must match the w holeline $H ISTSIZE number of previous commands to
keep availablew hilebashis running $H OME homedirectoryforcdcommand and
value used for tilde expansion $H OSTFILE filein format of/etc/hoststo usefor
hostname completion $H OSTNA ME nameofthe current host $H OSTTYPE stringdescribingthe current host $IFS field s eparators (space,tab,new line) $IG N OREEOF for interactive shells,the numberof
consecutive EOFs that must be entered beforebashactuallyexits $INPUTRC name of readline startup file,
overrides˜/.inputrc $LA N G nameofcurrent locale
$LC_ALL currentlocale;overrides$LA N G and other$LC_variables
$LC_COLLATE currentlocalefor character collation, includes sorting results offilename expansion
$LC_CTYPE current locale for characterclass functions (seePatterns)
$LC_MESSA G EScurrent locale for translating$"..." strings
$LINENO line numberofline beingexecuted in script or function
$MA CH TYPE astringin G N U cpu-company-system format describing the machine runningbash
$MA IL nameofamailfile,ifany
$MA ILCHECK check for mail everynseconds (60 default)
$MA ILPATH filenames to checkfor new mail;uses :separator;filenamemaybe follow ed by ?message; $_ in message is matched mail filename.Overrides $MA IL
$OLD PW D previous w orkingdirectory
$OPTA RG value oflast argument processed by getopts
$OPTERR if set to 1, dis play error messages fromgetopts(default:1)
$OPTIND indexoflast argument processed by getopts
PRE-
DEFI
N ED
VA RI
A BLES
(
continued)
11
$OSTYPE string describing the operating system running bash
$PATH command search path $PIPESTATUS[*] arrayvariable containingexit
status values from processes in the most recentlyexecuted foreground pipeline
$PPID process id ofshell’s parent $PROMPT_COMMA N D command to run beforeeach
primaryprompt
$PS1 primary prompt string
( )
$PS2 secondaryprompt string(>) $PS3 select command prompt
string(#?)
$PS4 tracingprompt string(+) $PW D current w orkingdirectory $RA N DOM set eachtimeit’s referenced, $REPLY set by theselectandread
commands
$S ECONDS number of seconds since s hell invocation
$SH ELL nameofthis shell
$SH ELLOPTS colon-separated list ofthe enabled shell options forset $SH LVL incremented byoneforeach
s ub-bash
$TIMEFORMA T format string for output of time keyw ord. Special constructs introduced by%. %[p][l]R elapsed secs %[p][l]U us erCPU secs %[p][l]S system C PU secs %P CPU percentage %% literal%
Optionalpgives the precision, the number of digits afterthe decimal point; it mus t be betw een 0and 3.Optionall produces alongerformat,in the formMMmSS.FFs $TMOUT number of seconds to w ait
during prompt before terminating
$UID the real us erid (readonly)
PRE-
DEFI
N ED
VA RI
A BLES
(continued)Functions run in the same process as the callingscript, and sharethe open files and current directory.They access theirparameters likeascript,via$1,$2and so on.$0does not change.returnmaybe used inside a function or.script. Functions sharetraps w ith the parent script, except forDEBUG.Functions may be recursive,and mayhave local variables,declared us ing declare,local,ortypeset.Functions maybe exported into theenvironment w ith .
FUNCTI
ONS
Redirections are doneleft toright,afterpipes are set up. Defaultfile descriptors arestdinandstdout.File descriptors above 2 aremarked close-on-exec. &>w ord sendstdoutandstderrtow ord >&w ord sendstdoutandstderrtow ord [n]<file usefilefor input
[n]>file usefilefor output
[n]>|file like>,but overridesnoclobber [n]>>file like>but append tofileifit exists [n]<>file openfilefor read/w rite(default:fd0) [n]<&m duplicateinput file descriptor fromm [n]>&m duplicateoutput filedescriptor fromm [n] closeinput file descriptor
[n] closeoutput file descriptor [n]<<w ord
input comes from the shellscript;treat aline w ith w ordas EOF on input.Ifanyofw ordis quoted,no additional processingis done on input bythe shell. Otherw ise:
• dovariable,command,arithmetic substitutions • ignoreescaped new lines
• use\to quote\,$,`,and first character ofw ord [n] w ord as above,but w ith leadingtabs ignored Of&>and>&,the first is preferred.It is equivalent to >w ord2>&1.
I
NPUT/
OUTPUT
A ll s ubstitutions and I/O redirections are performed beforeacommand is actuallyexecuted.
bashmaintains an internal has h table for caching external commands.Initially,this tableis empty.A s commands are found bysearchingthe directories listed in$PATH,theyare added to thehas htable.
The command searchorderis shellfunctions first,bui lt-in commands second,and external commands (first in the internalhas htable,and then via$PATH)third.
EX ECUTI
ON ORDER
Signal handlingis done w ith thetrapbuilt-in command. Thew ordargument describingcode to execute upon receipt of the signalis scanned tw ice bybash;once w hen thetrapcommand is executed,and again w hen the signalis caught.Thereforeit is best tousesingle quotes for thetrapcommand.Traps are executed in order of signal number.You cannot changethe status ofasignal that w as ignored w hen the shellstarted up. Traps onDEBUG happen after commands are executed. Backgrounded commands (those follow ed by&)w ill ignoretheSIG IN TandSIG QUITsignals ifthemonitor option is turned off.Otherw ise,theyinherit thevalues ofthe parentbash.
SI
G N A LS
A ND
TRAPS
A rrays in bashhave no limits on the number of elements. A rrayindices start at 0.A rraysubscripts can bearithmeticexpressions.A rray elements need not be contiguous.bashdoes not have associative
A RRAYS
!pipeline
executepipeline.Ifexit status w as non-zero,exit zero.Ifexit status w as zero,exit 1
casew ordin[[(]pat 1[|pat 2]...)list;;]...esac
executelistassociated w ithpatthat matchesw ord. Field s plittingis not done forw ord.patis abash pattern (seePatterns).|is us ed to indicatean OR condition.Us eleading(ifcaseis ins ide$() forname[inw ords];dolist;done
sequentiallyassign eachw ordtonameand execute list.Ifin w ords is missinguse the positional parameters
[function]func() {list;}
define functionfunc,bodyislist(seeFunctions) iflist1;thenlist2[;eliflist3;thenlist4]...[;elselist5];fi
if executinglist1returns successful exit status, executelist2else...
selectname[inw ords];dolist;done
print amenu ofw ords,prompt w ith$PS3and read a line fromstdin,savingit in$REPLY.Ifthe line is the number of one of thew ords,setnameto it, otherw isesetnameto NULL.Executelist.Ifin w ords is missing use the positional parameters. bashautomaticallyreprints the menu at the end of the loop
time[ ]pipeline
executepipeline;print elapsed,system and user times onstderr.
print times in POSIX format
The$TIMEFORMA Tvariable controls the format of the output if is not us ed.bashuses thevalue $’\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS’ifthereis no value for$TIMEFORMA T
untillist 1;dolist 2;done
likew hilebut negatethe termination test w hilelist 1;dolist 2;done
executelist 1.If last command in list 1had a successful exit status,executelist 2follow ed by list 1.Repeat until last command inlist 1returns an unsuccessful exit status
((...))
arithmetic evaluation,likelet "..." [[expression]]
evaluateexpression,return success ful exit status if true, unsuccessful if false (see Conditional Expressionsfor details)
(list)
executelistin as ub-shell {list;}
executelistin the current shell
CONTROL COMMA N DS
Us ed w ith the[[...]]compound command,w hich does not do pattern expansion orw ord splitting. string true ifstringis not NULL
file true iffileexists ( is preferred) file true iffileis ablockdevice file true iffileis acharacterdevice file true iffileis adirectory file true iffileexists file true iffileis aregularfile
file true iffilehas setgid bit set file true iffilegroup is effective gid file true iffileis asymbolic link file true iffilehas stickybit set file true iffileis asymbolic link string true ifstringhas non-zero length file true iffileexists and w as modified since
last read option true ifoptionis on
file true iffileow neris effective uid file true iffileis afifo (named pipe) file true iffileis readable file true iffilehas non-zero size file true iffileis asocket filedes true iffiledesis aterminal
file true iffilehas setuid bit set file true iffileis w ritable file true iffileis executable string true ifstringhas zero length file1 file2 true iffile1is new erthanfile2orfile2
does not exist
file1 file2 true iffile1is olderthanfile2orfile2 does not exist
file1 file2 true iffile1andfile2are thesamefile string==pattern
true ifstringmatchespattern string!=pattern
true ifstringdoes not matchpattern string1<string2
true ifstring1is beforestring2 string1>string2
true ifstring1is afterstring2 exp1 exp2true ifexp1equalsexp2 exp1 exp2true ifexp1does not equalexp2 exp1 exp2 true ifexp1is less thanexp2 exp1 exp2 true ifexp1is greater thanexp2 exp1 exp2 true ifexp1is less than or equal toexp2 exp1 exp2true ifexp1is greaterthan or
equal toexp2
(expression) true ifexpressionis true,for grouping !expression true ifexpressionis false
exp1&&exp2 true ifexp1A N Dexp2aretrue exp1||exp2 true ifexp1ORexp2is true
Iffileis/dev/fd/n,then,ifthereis no/dev/fddirectory, file descriptorn is checked.Otherw ise,the real /dev/fd/nfileis checked.Linux,FreeBSD,BSD/OS (and maybe others)return info forthe indicated file descriptor,instead oftheactual/dev/fddevice file. Both &&and ||are short circuit. Operands of comparison operators undergoarithmetic evaluation. For==and!=,quoteanypartofpatternto treat it as a string.
CON DI
TI
ON A L EXPRESSI
ONS
These commands are executed directly bythe shell. A lmost allaccept to marktheend ofoptions. .file
sourcefile
read and execute commands from file. If arguments,saveand restore positional params. Search$PATH;ifnothingfound,lookin the current directory
: nullcommand;returns 0exit status [ seetest
alias[ ][name[=value]...]
createan alias.W ith no arguments, print all aliases.W ithname,print alias value forname
printaliasbeforeeachalias bg[jobid]
putjobidin thebackground bind[ map][ ]
bind[ map][ func][ keyseq][ func] bind[ map] file
bind[ map]keyseq:func
dis play and/or modifyreadlinefunction and key bindings.Thesyntaxis sameas for˜/.inputrc
file read new bindings fromfile
list the names ofallreadlinefunctions map us ethekeymapmap
listreadlinefunctions and bindings forre-reading
listreadlinefunctions and bindings func show w hich keys invokefunc keyseq remove bindings forkeyseq
listreadlinekeysequences and macros forre-reading
listreadlinekeysequences and macros func removekeybindings forfunc
listreadlinevariablenames and values forre-reading
listreadlinevariablenames and values break[n]
exit from enclosingfor,w hile,untilorselectloop. Ifnis supplied,exit fromn’th enclosingloop builtinshell-builtin[args...]
executeshell-builtin w ith given args and return status. Usefulfor the bodyofas hellfunction that redefines abuilt-in,e.g.,cd
cd[ ][dir]
changecurrent directory todir($H OMEdefault). Do directorypaths earch usingvalue of$CDPATH
us elogicalpath forcd ..,$PW D(default) us e physicalpath forcd ..,$PW D Ifbothare given,the last one on the command line w ins
cd[ ]
changecurrent directoryto$OLDPW D command[ ]name[arg...]
w ithout or ,executenamew ithargumentsarg us eadefault search path,not$PATH print aonew ord description ofname print averbosedescription ofname continue[n]
do next iteration ofenclosingfor,w hile,untilor selectloop.Ifnis supplied,iteraten’th enclosing loop
declare[afFirx][ ][name[=value]] typeset[afFirx][ ][name[=value]]
set attributes and values of variables.Inside functions,createnew copies ofthevariables.Using +instead of turns attributes off.W ith no names or attributes, print every variable’s nameand attributes
nameis an array eachnameis afunction
don’t show function definitions (bodies) nameis an integer;arithmetic
evaluation is done upon assignment marknamesreadonly
marknames forexport dirs[ ][+n][n]
dis playthe directorystack
+n s how n’th entryfrom left,n 0 n s how n’th entryfrom right,n 0
clearthe directorystack print alongerformat listing print the stackone entryperline print the stackone entryperline,w ith indexnumbers
disow n[ ][ ][job...]
w ith no options,removenamedjobs from the table ofactive jobs
removeormark(w ith )alljobs markeachjobto not receive aSIG H UP w henbashterminates
us ew ith to markjust runningjobs echo[ ][w ords]
echow ords; is not special
expand \-escapes (seeecho(1)) never expand \-escapes don’toutput trailingnew line printfis more portable
enable[ ][ file][name...]
enableand disableshell built-ins, or load and unload new built-ins from shared library files. Disablinga built-in allow s useofadiskfilew ith the samenameas abuilt-in
print allbuilt-ins ,w ith theirstatus deleteabuilt-in loaded w ith file load a new built-innamefromfile
disablename,orprint disabled built-ins w ith nonames
print enabled built-ins
print onlyPOSIX special built-ins eval[w ords]
evaluatew ordsand executeresult exec[ name][ ][w ords]
executew ordsin placeofthe shell.Ifredirections only,changethe shell’s open files
usenameforargv[0] clearthe environment first placea onargv[0](likelogin(1)) Iftheexecfails,non-interactive shells exit,unless thes hoptoptionexecfailis set
exit[n]
exit w ith return valuen.Use$?ifnon
BUI
LT-
I
N COMMA N DS
(continued)17
export[ ][name[=value]...]
w ith no arguments, print names and values of exportedvariables. Otherw ise,exportnamesto the environment of commands
names referto functions stop exportingeachname printexportbeforeeach variable fc[ editor][ ][first[last]]
print arangeofcommands fromfirsttolastfrom last $H ISTSIZEcommands
runeditorifs upplied;ifnot,us efirst of $FCEDIT,$EDITOR,orvion
commands;executeresult(s)
list on s tandard output instead ofediting don’t print line numbers
reverse order of commands [old=new][command]
s ubstitutenew foroldincommand(orlast command ifnocommand)and executethe result
fg[jobid]
putjobidin the foreground getoptsoptstringname[arg...]
parse parameters and options (seebash(1)) hash[ ][ file][name]
w ithno arguments,print thehas htable contents, givinghit count and filename
file enterfilefornamein thehas htable clearthe internal has htable A ssignment to$PATH also clears thehas htable help[pattern]
print help.W ithpattern,print help about allthe commands that matchpattern
history[n] [file] history[ ]
arg[...] arg[...]
w ith no options, print the command history.A n argument ofnprints onlynlines.Ifs upplied,use fileinstead of$H ISTFILE
append new historylines to historyfile clearthe historylist
read new historylines in the fileinto the internal historylist
perform historys ubstitution and print the results
replaceinternal historyw ith contents of historyfile
placetheargsinto the historylist for later use
w ritetheinternal historyto the file jobs[ ][jobid...]
command[args...] list information about jobs
also list process id
onlylist stopped orexited jobs onlylist process groups onlylist runningjobs onlylist stopped jobs
replaceanyjobidin the command line w ith the correspondingprocess group ID, and executethecommand
BUI
LT-
I
N COMMA N DS
(continued)18
kill[sig]jobid...
kill[ signame][ signum]jobid...
sendSIG TERMor given signal to namedjobids. Signals are names listed in/usr/include/signal.h w ithorw ithout the prefix‘‘SIG ’’.Stoppedjobs get aSIG CON T first ifsigis eitherSIG TERM or SIG H UP
[sigs...]
list signal names and/or numbers.Ifsigis a numerical exit status,print the signal that killed the process
letarg...
evaluateeachargas an arithmeticexpression;exit 0 if the last expression w as non-zero,1otherw ise (seeArithmeticEvaluation)
local[name[=value]...]
createvariables w ith the given values local to a function. W ith no operands , print a list oflocal variables.Mustbe used ins ide afunction
logout
exit alogin s hell popd[ ][+n][n]
remove entries from the directorystack.W ith no arguments,removethe top entryandcdthere +n removen’th entryfrom left,n 0
n removen’th entryfrom right,n 0 don’tchangedirectory
printfformat[arg...]
print output likeA N SICprintf,w ith extensions %b expand escape sequences in s trings %q print quotedstringthat can be re-read Format conversions are reused as needed pus hd[ ][dir]
pus hd[ ][+n][n]
add an entry to the directory stack.W ith no arguments,exchangethe top tw o entries
+n rotatethestackso that then’th entryfrom left is at the top,n 0 n rotatethestackso that then’th
entryfrom right is at the top,n 0 don’tchangedirectory
dir pushdiron the stackandcdthere pw d[ ]
print w orkingdirectoryname print logical path (default) print physical path
Ifbothare given,the last one on the command line w ins
name][ ][ prompt][names...]
readstdinand assign tonames.$IFSs plits input. $REPLYis set ifnonamegiven. Exit0unless e nd-of-fileencountered
read w ords into indexed arrayname usereadlineifreadingfrom aterminal printpromptifreadingfrom aterminal beforereading
at end ofline does not do line continuation
BUI
LT-
I
N COMMA N DS
(continued)19
readonly[ ][name=value...]
marknamesread-only;print list ifnonames eachnamemust be an array eachnamemust be afunction printreadonlybeforeeach variable return[n]
exit function or.script w ith return valuen.W ith no n,return s tatus oflast command.Ifnot in function or.script,print an error message
set[options][ option][w ords]
set flags and options (seeOptions Toset).w ordsset positional parameters
set[+options][+ooption][w ords] unset flags and options s hift[n]
rename positional parameters;$n+1=$1... ndefaults to 1
s hopt[ ][option...]
print or changevalues ofshell options.W ith no arguments,print shelloption information
onlychange options print settings for re-reading quiet mode;exit status indicates option status
set (enable)given option;w ith no options,print thosethat are set unset (disable)given option;w ith no options,print thosethat are unset (SeeOptions Tos hopt)
s us pend[ ]
s us pend the shelluntilSIG CON Tis received forcesuspension,even for login s hell test
evaluate conditional expressions (seeOptions To
testandConditionalExpressions) times
print accumulated process times trap[ ][w ord][sigs]
executew ordif signalinsigs received.sigs are numbers or signal names w ith or w ithout ‘‘SIG ’’. W ith now ordorsigs,print traps.W ith now ord, resetsigsto entrydefaults.Ifw ord sigs to entrydefaults.Ifw ordis the nullstring,ignore sigs.Ifsigsis0orEXIT,executew ordon exit from shell.Ifsigs is DEBUG,run w ordafterevery command.
print alist ofsignal names and numbers print traps w ith quoting
type[ ]name...
describe how the shellinterpretsname print allpossibleinterpretations ofname
print the nameofthe fileto executeif nameis an external program
print akeyw ord describingname
BUI
LT-
I
N COMMA N DS
(continued)ulimit[type][options][limit] set or print per-process limits type(default is both):
hard limit softlimit options:
all(dis playonly) corefilesize ‘‘k’’ofdatasegment maximum filesize ‘‘k’’ofphysical memory maximum file descriptor +1 sizeofpipe buffers
‘‘k’’ofstacksegment cpu s econds
maxprocesses for oneuser ‘‘k’’ofvirtualmemory
is assumed ifno options aregiven.The sizefor is in 512-byteblocks;theothers are in s izes of 1024 bytes
umask[ ][mask]
set filecreation permissions maskto complement of maskifoctal,or symbolic value as inchmod.W ith no arguments,print current mask.A n octalmaskis permissions to remove, asymbolic mask is permissions to keep
print output for re-reading print current maskin s ymbolicform unalias[ ][names]
removealiasesnames removeallaliases unset[ ][names]
unset variablesnames(sameas ) unset functionsnames unset variablesnames
Unsetting LIN EN O, MA ILCHECK, OPTARG, OPTIND,RA NDOM,SECON DS,TMOUT and _ removes their special meaning, even if us ed afterw ards
w ait[jobid...]
w ait for jobjobid;ifnojob,w ait for allchildren
BUI
LT-
I
N COMMA N DS
(continued)Thetestcommand,and its synonym[...],are built-in to bash.The command accepts allofthe options listed in theConditionalExpressionssection. H ow ever,since itis acommand,options and arguments must be quotedto get properbehavior,and normal pattern expans ion and field s plittingare done.Parentheses used for grouping must be quoted.A rithmeticexpansion is not done for numeric operators,and pattern matchingis not done for==and!=.testcomplies w ithPOSIX.
The and options have the follow ingmeanings, instead oftheones listed inConditionalExpressions:
logical A N D logical OR
OPTI
ONS
TO
te
st
Thesetcommand is complicated.H ereis asummary. Use+instead of to turn options off.W ith no arguments,setprints the names and values of all variables.
set[abBCefhH kmnpPtuvx][ooption...][arg...] automaticallyexportvariables upon assignment
print job completion messages immediately,don’t w ait for next prompt enable braceexpansion (default) force>|to overw ritefor existingfiles exit upon non-zero exit from a command disable pattern expans ion
save command locations in the internalhas htable(default) enable!-style history(default) placeallvariableassignments in the environment (obsolete) run background jobs in theirow n process group,print amessage w hen theyexit;set automaticallyfor interactive shells on job controlsystems read commands w ithout executingthem (ignored ifinteractive)
set options;w ith no arguments,print current settings
allexport sameas braceexpand sameas emacs useanemacs-styleline
editor (default) errexit sameas hashall sameas histexpand sameas history enable history ignoreeoflikeIG N OREEOF=10 keyw ord sameas monitor sameas noclobbersameas noexec sameas noglob sameas notify sameas nounset sameas onecmd sameas physical sameas
posix obeythe POSIX 1003.2 standard
privilegedsameas verbose sameas
vi us eavi-styleline editor xtrace sameas
don’t read$EN V,donot takeshell functions from environment,and ignore options in$SH ELLOPTSenvironment variable
follow the physical directorystructure for commands that changethe directory read and execute one command, then exit
makeit an error to substitutean unset variable
print input lines as they’reread
OPTI
ONS
TO
se
t
print commands as they’reexecuted, preceded byexpanded value of$PS4. Output is quotedforlaterreuse turn off , ,s top lookingfor flags; anyremainingargs set the
positional parameters
do not changeflags;set pos itional parameters from argument list; w ith no args,unset the positional parameters
OPTI
ONS
TO
se
t
(continued)Thes hoptcommand sets or unsets anumberofoptions that affect how bashbehaves.This section describes each option’s effect w hen enabled.Unless noted,they are alldisabled bydefault.
cdable_vars
treat an argument tocdthat is not adirectoryas a variablew hose value is the directoryname cds pell
attempt to correct minor spelling errors in arguments tocd.Errors tried are transposed characters,a missing character or an extra character.Onlyobeyed in interactive shells checkhash
checkthat a command in thehas htablestill exists beforetrying to execute it.Ifit does n’t, search $PATH
checkw ins ize
check the w indow sizeafter eachcommand and update$LINESand$COLUMN S
cmdhist
attempt to save alllines ofamulti-line command in the historyfileas one line,for easyre-editing dotglob
include files w hosenames begin w ith.in path expansions
execfail
keep non-interactive shells from exitingw henexec fails
expand_aliases
expand aliases as described inAliases.Enabled automaticallyin interactive shells
extglob
enabletheextended pattern matchingfacilities (see
Patterns) histappend
append the current historyto$H ISTFILEupon exit, instead ofoverw ritingit
histreedit
ifusingreadlineand a historys ubstitution fails,the us er can re-edit the line
histverify
if usingreadline,load the results of history s ubstitution intoreadlineforfurther editing hostcomplete
ifusingreadline,attempt host completion on w ord containing@
huponexit
sendSIG H UPto alljobs w henbashexits interactive_comments
in interactive shells,aw ordstartingw ith#starts a
OPTI
ONS
TO
s hopt
lithist
ifcmdhist is also enabled,save multi-line commands w ith new lines,not semi-colons
mailw arn
print aw arningmessageifafile beingchecked for mail w as accessed s ince the last time it w as checked
nocaseglob
do a case-insensitive match w hen expanding pathnames
nullglob
removepatterns that don’t matchanyfile,ins tead ofleavingthem unchanged in the command line promptvars
do parameterexpansion on the prompt variables before printingthem.Enabled bydefault s hift_verbose
print an error message w hen the s hift count is greater than thenumberof positional parameters sourcepath
use$PATH tofind shellfiles given to the.and sourcecommands.Enabledbydefault
OPTI
ONS
TO
s hopt
(continued)# startofcomment;terminated bynew line | (pipe)connects tw o commands
; command separator
& run process in background; defaultstdin from/dev/nullifno job control && onlyrun follow ingcommand ifprevious
command completedsuccessfully || onlyrun follow ingcommand ifprevious
command failed
´ enclosestringto betaken literally " enclosestringto have variable,command
and arithmetic substitution only $() in-line command s ubstitution (new style) ` in-line command s ubstitution (old style) ((...)) arithmetic evaluation,likelet "..." $((...)) in-line arithmetic evaluation \ treat follow ingcharacterliterally \new line line continuation
SPECI
AL
CH A RA CTERS
Jobs can be represented as follow s:
jobid the job identifierforajob,w here: %% current job
%+ current job previous job
%?str job uniquelyidentified bystr %n job numbern
%pref job w hose command line begins w ithpref
Us ually,aprocess ID maybe used ins teadofajobid. Commands that takeajobidus ethe currentjob if no jobidis supplied.
Traps onSIG CH LDexecutew heneverajob completes. Thecommandsfgandbgare onlyavailableon s ystems that support job control.This includes Linux, BSD
Thereadlinelibraryimplements command line editing. By default,it provides an emacs editing interface, although aviinterface is available.readline is initialized eitherfrom the file named by$INPUTRC(if set), or from ˜/.inputrc.In that file, you can use conditionals, define key bindings for macros and functions,and set variables.
From thebashlevel,thebindcommand allow s you to add,remove and change macro and key bindings. Therearefive input modemap names that control the action taken for eachinput character.Themap names areemacs,emacs-standard,emacs-meta,emacs-ctlx, vi,vi-command,andvi-insert.emacsis the sameas emacs-standard,andviis the sameasvi-command. Youchoos ew hich editor you preferw ith
or in your˜/.bashrcfile,or at runtime. readlineunderstands thecharacter names DEL,ESC, LFD,NEW LINE,RET,RETURN,RUBOUT,SPA CE,SPCand TA B.
REA DLI
NE
Directives in the.inputrcfile provide conditional and includefacilities similar to the C preprocessor. $include
includea file,e.g.,asystem-w ide/etc/inputrcfile $if
start a conditional,for terminal or application specific settings.Youcan test the follow ing: application= test theapplication,e.g.bashorgdb mode= test the editingmode,emacsorvi term= test the terminal type
The use ofapplication=is optional;e.g.,$ifBash $else
startthe ‘‘else’’partofa conditional $endif
finis haconditional
REA DLI
NE
DI
RECTI
VES
Keys bound to amacro placethe macro text into the input;keys bound to afunction run the function. Youcan usetheseescape sequences in bindings: \a alert(bell) \r carriagereturn \b backspace \t horizontal tab (TA B)
controlprefix \v verticaltab \d delete(DEL) \\ backslash \e escape (ESC) \" literal" \f form feed \´ literal´
metaprefix \ddd octalvalueddd \n new line \xhhh hexvaluehhh Macros and function bindings looklike: macro: key-seq:"text" function: key-seq:function-name
Macros have quotedtext on theright of the colon; functions have function names.A key-seqis eithera singlecharacter or charactername(s uchas ), or aquotedstring ofcharacters (singleor double quotes).
REA DLI
NE
KEY BI
N DI
N G S
25
Variables control different aspects ofreadline’s behavior.You s et avariablew ith
setvariable value
Unless otherw isenoted,values hould beeitherOnor Off.Thedescriptions below describe theeffect w hen thevariable is On.Default values are show n in parentheses.
bell-style(audible)
defines how readlines hould ringthe bell: audible ringthe bell none neverringthe bell visible flash the screen comment-begin(#)
ins ert this string forreadline-insert-comment, (bound toM-#inemacsmodeand to#invimode) completion-ignore-case(Off)
ignore casew hen doingcompletions completion-query-items(100)
ifthe number of completion items is less than this value,placethem in the command line.Otherw ise, askthe useriftheys hould beshow n
convert-meta(On)
treat characters w ith theeighthbit set as the meta version ofthe equivalent seven bit character disable-completion(Off)
do not do completion editing-mode(emacs)
set the initial editing mode.Possible values are emacsorvi
enable-keypad(Off)
attempt to enabletheapplication keypad.This may be needed to makethearrow keys w ork
expand-tilde(Off)
attempt tilde expansion as partofw ord completion input-meta(Off)
meta-flag(Off)
enableeight bit input.The tw o variable names are synonyms
keymap(emacs)
set the current keymap.SeeReadlinefor alist of allow ed values.Theediting-modevariable also affects thekeymap
mark-directories(On)
append a/to completed directorynames mark-modified-lines(Off)
placea*at the front of modified historylines output-meta(Off)
print characters w ith theeighthbit set directly,not asM-x
print-completions -horizontally(Off)
dis playcompletions horizontally,w ith the matches sortedalphabetically,instead ofverticallydow n the screen
show -all-if-ambiguous(Off)
immediately list w ords w ith multiple possible completions,ins tead ofringingthe bell
visible-stats(Off)
w hen listing possible completions, append a characterthat denotes the file’s type
REA DLI
NE
VA RI
A BLES
Moreinformation aboutreadlinecan befound on-lineat http://w w w .ssc.com/ssc/bash.