• No results found

Bash Quick References

N/A
N/A
Protected

Academic year: 2022

Share "Bash Quick References"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

Bash Quick References

B ash (B our ne A gain Shell) is a shell lang uage build on - top of t he or ig nal B our ne Shell w hich was dis t r ibu te d w i t h V 7 Uni x in 1979 and be c ame t he s t andard for w r i t ing

shell s cr ipt s . Today i t is pr imar y to mos t L inu x dis t r ibu t ions , Mac OS and i t has e ven re cent l y be en enable d to r un on W indow s t hroug h s ome t hing c alle d W SL ( W indow s Subs y s tem for L inu x).

Flag - e - a -f - s - d - b - c - p - h - L -S

- t

- r - w -x - g - u - k - O - G - N

f1 - nt f 2 f1 - ot f 2 f1 - e f f 2

!

Desc r i pt io n F ile e x is t s

F ile e x is t s (ident ic al to - e bu t is depre c ate d and ou tdate d) File is a regular file (not a direc tor y or device file)

file is not zero size file is a direc tor y file is a block device file is a charac ter device file is a pipe

file is a symbolic link file is a symbolic link file is a socket

file (descriptor) is associated with a terminal device; this te s t opt ion may be us e d to che ck w he t her t he s tdin [ - t 0 ] or s tdou t [ - t 1 ] in a g i ven s cr ipt is a ter minal

file has read permission (for the user running the test) file has write permission (for the user running the test) file has execute permission (for the user running the test) set-group-id (sgid) flag set on file or direc tor y

set-user-id (suid) flag set on file.

s t ick y bi t s e t .

you are owner of file

group-id of file same as yours file modified since it was last read file f1 is newer than f2

file f1 is older than f2

files f1 and f2 are hard links to the same file

Not – re ver s e s t he s ens e of t he te s t s above (re t ur ns t r ue i f condi t ion abs ent).

Testing files in scripts is easy and straight for ward. This is where shell scripting star ts to show its glor y! In Bash you can do file testing for permissions, size, date, filet ype or existence.

File Te s t Op erator s

(2)

Job Identifiers

Job cont rol allow s you to s ele c t i vel y s top (suspend) t he e xe cu t ion of proce s s e s and cont inue t heir e xe cu t ion at a later point in t ime.

Not at io n

%N

% S

%? S

%%

% +

% -

%!

Desc r i pt io n Job number [N]

Invoc at ion (command - line) of job beg ins w i t h s t r ing S

Invoc at ion (command - line) of job cont ains w i t hin i t s t r ing S

"cur rent " job (las t job s toppe d in foreg round or s t ar te d in b ack g round)

"cur rent " job (las t job s toppe d in foreg round or s t ar te d in b ack g round) L as t job

L as t b ack g round proce s s

Compound Operators

Us e f ul for boolean e x pre s sions and is similar to && and ||. T he compound operator s wor k w i t h t he te s t command or may occur w i t hin sing le bracke t s [ < e x pr > ].

Flag - a - o

Desc r i pt io n log ic al and log ic al or

String Comparison Operators

St r ing comp ar is on in B ash.

Flag

=

= =

! =

<

>

-z - n

Desc r i pt io n is e qual to s ame as above is not e qual to

is le s s t han A SCII alphabet ic al order is g reater t han A SCII alphabe t ic al order s t r ing is null (i.e. zero leng t h)

s t r ing is not null (i.e. ! zero leng t h) Flag

- e q - ne - g t - ge - l t - le

<

< =

>

>=

Desc r i pt io n is e qual to is not e qual to is g reater t han

is g reater t han or e qual to is le s s t han

is le s s t han or e qual to

is le s s t han – place w i t hin double p arent he s e s

is le s s t han or e qual to (s ame r ule as pre v ious row) is g reater t han (s ame r ule as pre v ious row)

is g reater t han or e qual to (s ame r ule as pre v ious row)

Integer Comparison Operators

How to comp are integer s or ar i t hme t ic e x pre s sions in shell s cr ipt s .

(3)

Signal s

UNI X Sy s tem V Sig nals . Na m e

SIG HUP SIG IN T SIGQUI T SIG IL L SIG T R A P SIG IOT SIG EM T SIG F PE SIG K IL L SIGBUS SIGSEG V SIGS Y S SIG PIPE.

SIG A L R M SIG T ER M

N u m b e r 1

2 3 4 5 6 7 8 9 10 11 12 13 14 15

Ac t io n e x i t e x i t

core dump core dump core dump core dump core dump core dump e x i t

core dump core dump core dump e x i t

e x i t e x i t

Desc r i pt io n Hang s up Inter r upt s . Q ui t s .

Illegal ins t r uc t ion.

Trace t rap.

IOT ins t r uc t ion.

M T ins t r uc t ion.

F lo at ing point e xcept ion.

K ills (c annot be c aug ht or ig nore d).

B us er ror.

S eg ment at ion v iolat ion.

B ad ar g ument to s y s tem c all.

Wr i te s on a pipe w i t h no one to read i t . A lar m clock .

S of t ware ter minat ion sig nal.

Re se r ve d E x it Co de s

Us e f ul for debug g ing a s cr ipt . E x i t t ake s integer ar g s in t he range 0 -2 55.

E x it Co d e No.

1 2 126 127 128 128+n 13 0

Desc r i pt io n

C atchall for general er ror s Misus e of shell buil t ins

Command invoke d c annot e xe cu te Command not found

Invalid ar g ument to e x i t Fat al er ror sig nal "n"

S cr ipt ter minate d by Cont rol - C Co ns t r u c t

&&

||

Desc r i pt io n and cons t r uc t or cons t r uc t

Li s t Con s truc t s

Provides a means of processing commands consecutively and in effec t is able to replace comple x i f/ t hen /c as e s t r uc t ure s .

(4)

S ending Control Signal s

You c an us e t he s e key - combinat ions to s end sig nals

C he ck your s t t y s e t t ing s . Suspend and re sume of ou t pu t is usuall y dis able d i f you are using "moder n" ter minal emulat ions . T he s t andard x ter m suppor t s Ct r l+S and Ct r l+ Q by de faul t .

Key Co m b o Ct r l+ C

Ct r l+Y

Ct r l+Z

Desc r i pt io n

T he inter r upt sig nal , s ends SIG IN T to t he job r unning in t he foreg round.

T he delaye d suspend charac ter. C aus e s a r unning proce s s to be s toppe d w hen i t at tempt s to read inpu t f rom t he ter minal. Cont rol is re t ur ne d to t he shell , t he us er c an foreg round , b ack g round or k ill t he proce s s . De - laye d suspend is onl y available on operat ing s y s tems suppor t ing t his feat ure.

T he suspend sig nal , s ends a SIG T S T P to a r unning prog ram , t hus s top - ping i t and re t ur ning cont rol to t he shell.

Permi s sion s

Now you may k now w hat t hat arc ane look ing s t r ing r w x r w x r w x is w hen you invoke ls Co d e- l

s s t 0 - 4 r 2 w 1 x u g o

Desc r i pt io n

s e t uid w hen in us er column s e t g id w hen in g roup column s t ick y bi t

T he acce s s r ig ht t hat is suppos e d to be on t his place is not g rante d.

read access is granted to the user categor y defined in this place

write permission is granted to the user categor y defined in this place execute permission is granted to the user categor y defined in this place

us er per mis sions g roup per mis sions ot her s per mis sions S y m b ol

- d l c s p b

M e a ni ng Regular file Dire c tor y

(Sy mbolic) L ink C harac ter de v ice S ocke t

Name d pipe B lock de v ice

File Ty p e s

This is ver y different from Windows but straight for ward once you get it. I'll expand t his s e c t ion s oon w i t h more conte x t .

(5)

String Manipulation

B ash suppor t s a sur pr ising l y big number of s t r ing operat ions! Unfor t unatel y, t he s e tools lack a unified focus. Some are a subset of parameter substitution, and others fall under the func tionalit y of the UNIX expr command. This results in inconsistent command syntax and overlap of func tionalit y.

MacOS built-in bash is from 2007 and won't suppor t many of these.

Pat te r n

${# var}

${var%pat tern}

${var%%pat tern}

${var:position}

${var:num1:num2}

${var#pat tern}

${var##pat tern}

${var/pat tern/string}

${var//pat tern/string}

${!prefix*}

${var,}

${var,pat tern}

${var,,}

${var,,pat tern}

${var^}

${var^pat tern}

${var^ ^}

${var^ ^pat tern}

${string /substring /replacement}

${string //substring /replacement}

${string /#substring /replacement}

${string /%substring /replacement}

expr match "$string" '$substring' expr "$string" : '$substring'

Desc ript ion

Find the leng th of the string

Remove from shor test rear (end) pat tern Remove from longest rear (end) pat tern Extract substring from $var at $position Substring

Remove from shor test front pat tern Remove from longest front pat tern

Find and replace (only replace first occurrence) Find and replace all occurrences

Expands to the names of variables whose names begin with prefix.

Conver t first character to lowercase.

Conver t all characters to lowercase.

Conver t first character to uppercase.

Conver t all character to uppercase.

Replace first match of $substring with $replacement Replace all matches of $substring with $replacement If $substring matches front end of $string, substitute

$replacement for $subs t r ing

If $substring matches back end of $string, substitute

$replacement for $subs t r ing

Leng th of matching $substring* at beginning of $string Leng th of matching $substring* at beginning of $string Fi le

/etc /profile

~.bash_profile

~/.bash_login

~.profile

~/.bashrc

I nf o

Executed automatically at login

Whichever is found first is executed at login.

Is read by ever y nonlogin shell.

Sp e cial File s

Files that are read by the shell. Listed in order of their execution.

(6)

S y m b ol

;

&

( )

|

< > &

* ? [ ] ~ + - @ !

" ' \

$

#

sp ace t ab ne w line

Lite ra l M e a ni ng Command s eperator B ack g round e xe cu t ion Command g rouping Pipe

Re dire c t ion s y mbols F ilename me t acharac ter s Us e d in quot ing charac ter s

Var iable, command or ar i t hme t ic subs t i t uion St ar t a command t hat ends on a linebreak Word s eperator s

Quoting

T he follow ing te x t show s charac ter s or t hat ne e d to be quote d i f you want to us e t heir li teral s y mbols and not t heir spe cial meaning.

Ever y t hing bet we en "..." is t aken li terall y, e xcept $ (dollar) ` (b ack t ick) and " (dou - ble - quot at ion).

Ever y t hing bet we en '...' is t aken li terall y, e xcept ' (sing le - quote).

T he charac ter s follow ing \ is t aken li terall y.

Us e \ to e s c ape any t hing in "..." or '...'

Using $ be fore "..." or '...' c aus e s s ome spe cial behav ior. $"..." is t he s ame as "..."

e xcept t hat loc ale t ranslat ion is done. L ike w is e, $'...' is similar to $'...' e xcept t hat t he quote d s t r ing is proce s s e d for e s c ape s e quence s .

Co m ma n d

$0

$1 … $9

$ {10}

$*

Desc r i pt io n

Name of t he s cr ipt i t s el f Parame ter 1 ... 9

Posi t ional p arame ter 10

E x p ands to t he posi t ional p arame ter s , s t ar t ing f rom one.

W hen t he e x p ansion occur s w i t hin double quote s , i t

e x p ands to a sing le word w i t h t he value of each p arame ter seperated by the first of the IFS environment variable

Command Parameter s

Command p arame ter s , als o k now n as ar g ument s , are us e d w hen invok ing a B ash s cr ipt . Pat te r n

e x pr inde x " $s t r ing " $subs t r ing

e x pr subs t r $s t r ing $posi t ion

$leng t h

e x pr match " $s t r ing " ' \ ($sub - s t r ing \)'

e x pr " $s t r ing " : ' \ ($subs t r ing \)' e x pr match " $s t r ing " '.* \ ($sub - s t r ing \)'

e x pr " $s t r ing " : '.* \ ($subs t r ing \)'

Desc ript ion

Numerical position in $string of first character in $sub- string* that matches [0 if no match, first character counts as posi t ion 1]

E x t rac t $leng t h charac ter s f rom $s t r ing s t ar t ing at $posi - tion [0 if no match, first character counts as position 1]

E x t rac t $subs t r ing *, searching f rom beginning of $s t r ing

E x t rac t $subs t r ing * , searching f rom beginning of $s t r ing E x t rac t $subs t r ing *, searching f rom end of $s t r ing

E x t rac t $subs t r ing *, searching f rom end of $s t r ing

(7)

Co m ma n d

$ -

$ _

$$

$ ?

$@

$ #

$!

Desc r i pt io n Cur rent opt ions

T he under s core var iable is s e t a t shell s t ar t up and cont ains t he abs olu te file name of the shell or script being executed as passed in the argument list. Subsequently, it expands to the last argument to the previous com- mand, af ter expansion. It is also set to the full pathname of each command executed and placed in the environment expor ted to that command. When checking mail, this parameter holds the name of the mail file.

Process id of the shell

Exit status of the most recently executed command All arguments as separate words

Number of arguments

PID of most recently backgrounded process

Co m ma n d

!

! !

!n

! - n

!string

!?string?

^string1^string2^

! #

Desc r i pt io n

St ar t s a his tor y subs t i t u t ion Refers to the last command.

Refers to the <n>-th command line.

Refers to the current command line minus <n>.

Refers to the most recent command star ting with <string>

Refers to the most recent command containing <string> (the ending

? is opt ional)

Quick substitution. Repeats the last command, replacing <string1>

with <string2>.

Refers to the entire command line t yped so far.

Hi s tor y E x pan sion

Enables use and manipulation of previous commands.

E x p r ess io n

${parameter:-defaultValue}

Get default shell variables value

${parameter:=defaultValue}

Set default shell variables value

${parameter:? "Error Message"}

Display an error message if parameter is not set

Variable Op erations

Per form operations on variables.

G lo b

*

? +

!

Desc r i pt io n

Matches zero or more occurences of a given pat tern Matches zero or one occurences of a given pat tern Matches one or more occurences of a given pat tern

Negates any pat tern matches — reverses the pat tern so to sp eak t

B a sh Globbing

Bash cannot recognize RegEx but understand globbing. Globbing is done to filenames by the shell while RegEx is used for searching tex t.

(8)

O p e rat o r .

?

* + {N}

{N ,}

{N , M}

-

^

$

[aoei AOEI]

[^AOEIaoei ] [a -f ]

In b asic reg ular e x pre s sions t he me t acharac ter s " ? ", "+", "{ ", "|", "( ", and " )" los e t heir spe cial meaning ; ins tead us e t he b ack slash ver sions " \? " ... " \)". C he ck in your s y s tem document at ion w he t her commands using reg ular e x pre s sions suppor t e x tende d

e x pre s sions .

Effect

Matche s any sing le charac ter.

T he pre ce ding i tem is opt ional and w ill be matche d , at mos t , once.

T he pre ce ding i tem w ill be matche d zero or more t ime s . T he pre ce ding i tem w ill be matche d one or more t ime s . T he pre ce ding i tem is matche d e xac t l y N t ime s .

T he pre ce ding i tem is matche d N or more t ime s .

T he pre ce ding i tem is matche d at leas t N t ime s , bu t not more t han M t ime s .

Represents the range if it's not first or last in a list or the ending point of a range in a lis t .

Matche s t he empt y s t r ing at t he beg inning of a line; als o repre s ent s t he charac ter s not in t he range of a lis t .

Matche s t he empt y s t r ing at t he end of a line.

Matche s any 1 charac ter f rom t he lis t . Matche s any 1 charac ter, not in t he lis t ! Matche s any 1 charac ter in t he range a -f

Re gular E x pre s sions

A l way s us e quote s in your RegE x to avoid g lobbing

Character Class [:lower :]

[:upper :]

[:alpha:]

[:dig i t :]

[:alnum:]

[: xdig i t :]

[:sp ace:]

[:punc t :]

[:pr int :]

[:blank :]

[:g raph:]

[:cnt r l:]

Equivalent [a -z]

[A -Z ] [A -Z a -z]

[0 - 9]

[a -z A -Z0 - 9]

[0 - 9A - Fa -f ] [ \t \ n\ r \f \v]

[ [:g raph] ] [ \t]

[^ [:cnt r l:] ]

Explanation

Lowerc as e le t ter s . Upperc as e le t ter s .

A lphabet ic le t ter s , bot h upper- and lowerc as e.

Number s 0 - 9.

A lphanumer ic : bot h le t ter s (upper- + lowerc as e) and dig i t s He xade cimal dig i t s .

W hi te sp ace. Sp ace s , t abs , ne w line and similar.

Sy mbols (minus dig i t s and le t ter s).

Pr int able charac ter s (sp ace s include d).

Sp ace and t ab charac ter s onl y.

G raphic all y pr int able charac ter s e xcluding sp ace.

Cont rol charac ter s . Non - pr int able charac ter s .

Charac ter Cla s se s In BR E

A charac ter class [:CharClass:] is a set of predefined pat terns and comprpised of the follow ing :

(9)

B u i l t i n :

. [ alias bg bind break buil t in c aller c as e cd

command compgen comple te comopt cont inue de clare dir s dis ow n e cho enable e val

e xe c e x i t e x por t fc f g

ge topt s hash help his tor y i f

jobs k ill le t loc al logou t mapfile

pop d Desc r i pt io n

Equi valent to t r ue.

Reads and executes commands from a designated file in the current shell.

Is a synonym for test but requires a final argument of ].

Defines an alias for the specified command.

Re sume s a job in b ack g round mode.

Binds a key bo ard s e quence to a read line f unc t ion or macro.

E x i t s f rom a for, w hile, s ele c t , or unt il loop.

Executes the specified shell built-in command.

Re t ur ns t he conte x t of any ac t i ve subrou t ine c all

Changes the current direc tor y to the specified direc tor y.

Executes the specified command without the normal shell lookup.

Generates possible completion matches for the specified word.

Displays how the specified words would be completed.

Re sume s t he ne x t i terat ion of a for, w hile, s ele c t , or unt il loop.

De clare s a var iable or var iable t y pe.

Display s a lis t of cur rent l y remembere d dire c tor ie s .

Removes the specified jobs from the jobs table for the process.

Displays the specified string to STDOUT.

Enables or disables the specified built-in shell command.

Concatenates the specified arguments into a single command, and executes t he command.

Replaces the shell process with the specified command.

Forces the shell to exit with the specified exit status.

Sets the specified variables to be available for child shell processes.

Selec ts a list of commands from the histor y list.

Re sume s a job in foreg round mode.

Parses the specified positional parameters.

Finds and remembers the full pathname of the specified command.

Displays a help file.

Display s t he command his tor y.

Used for branching.

L is t s ac t i ve jobs .

Sends a system signal to the specified process ID (PID).

Evaluate s each ar g ument in a mat hemat ic al e x pre s sion.

Creates a limited-scope variable in a func tion.

E x i t s a log in shell.

Remove s ent r ie s f rom t he dire c tor y s t ack .

S h e l l B u i l t i n s

Shell builins are built into Bash are of ten ver y (if not ex tremely) fast compared to ex ternal programs. Some of the builtins are inherited from the Bourne Shell (sh) — these inherited commands will also work in the original Bourne Shell.

(10)

B u i l t i n pr int f pushd pwd read readonl y

re t ur n

s e t shi f t shopt s ource suspend te s t t ime s t rap t y pe

t y pe s e t ulimi t umask unalias uns e t unt il

wai t

w hile

Desc r i pt io n

Display s te x t using for mat te d s t r ing s . Adds a dire c tor y to t he dire c tor y s t ack .

Display s t he p at hname of t he cur rent wor k ing dire c tor y.

Reads one line of dat a f rom S T DIN , and as sig ns i t to a var iable.

Reads one line of dat a f rom S T DIN , and as sig ns i t to a var iable t hat c an ’ t be change d.

F orce s a f unc t ion to e x i t w i t h a value t hat c an be re t r ie ve d by t he c alling s cr ipt .

S e t s and display s env ironment var iable value s and shell at t r ibu te s . Rot ate s posi t ional p arame ter s dow n one posi t ion.

Tog g le s t he value s of var iable s cont rolling opt ional shell behav ior.

Reads and executes commands from a designated file in the current shell.

Suspends t he e xe cu t ion of t he shell unt il a SIGCON T sig nal is re cei ve d.

Returns an exit status of 0 or 1 based on the specified condition.

Display s t he accumulate d us er and s y s tem shell t ime.

Executes the specified command if the specified system signal is received.

Displays how the specified words would be interpreted if used as a com- mand.

De clare s a var iable or var iable t y pe.

Sets a limit on the specific resource for system users.

Sets default permissions for newly created files and direc tories.

Removes specified alias.

Removes the specified environment variable or shell at tribute.

Loop t hat is ver y similar to t he w hile - loop e xcept t hat i t e xe cu te s unt il t he te s t- command e xe cu te s succe s f ull y. A s long as t he te s t- command fails , t he unt il - loop cont inue s .

Make the shell wait for a job to finish.

Waits for the specified process to complete, and returns the exit status.

(11)

S y m b ol

#

$ ( )

$ ( )

(( ))

$ (( ))

$[ ]

[ ]

[ [ ] ]

< ( )

{ }

$ { }

|

<

>

||

&&

- - -

&

<< WOR D

<< -WOR D

<<' WOR D'

<< -' WOR D'

<<<

>>

' '

" "

\

/

Qu ic k Re f e r e nce us e d for comment s

$ us e d for p arame ter s and var iable s . Has a bunch of e dge c as e s . is us e d for r unning commands in a subshell.

is us e d for s av ing ou t pu t of commands t hat are s end to r un in a subshell.

is us e d for ar i t hme t ic .

is us e d for re t r ie v ing t he ou t pu t of ar i t hme t ic e x pre s sions , ei t her for us age w i t h a command or to s ave t he ou t pu t in a var iable.

depre c ate d integer e x p ansion cons t r uc t w hich is replace d by $ ((

)). Evaluate s integer s bet we en t he s quare bracke t s

is us e d for te s t ing and is a buil t- in. Is us e f ul in s ome c as e s for filename expansion and string manipulation.

is us e d for te s t ing. T his is t he one you should us e unle s s you c an t hink of a reas on not to.

Us e d for proce s s subs t i t u t ion and is similar to a pipe. C an be used whenever a command expec ts a file and you can use multi- ple at once.

is us e d for e x p ansion of s e quence s

is us e d for var iable inter polat ion and s t r ing manipulat ion.

is a pipe w hich is us e d for chaining commands toge t her.

used for feeding input to commands from a file

used for sending output to a file and erasing any previous con- tent in that file.

log ic al or log ic al and

used for option prefixes

used for the long-option prefixes us e d to s end a job to t he b ack g round

is us e d for here doc s

is us e d for here s t r ing s

is used to append output to a file.

sing le quote s are us e d to pre s er ve t he li teral value

double quote s are us e d to pre s er ve t he li teral value of all charac- ter s e xcept $, ` ` and \

b ack slash is us e d to e s c ape ot her w is e inter pre te d s y mbols /char- ac ter s w hich has a spe cial meaning

used for seperating the components of a filename

O ver v iew O f B a sh Sy mb ol s

Here we have gat here d a colle c t ion of all arc ane s y nt a x along w i t h a br ie f de s cr ip - t ion. A bunch of t he s e s y mbols are repeate d f rom ear lier bu t many are ne w - t his is a good s t ar t ing point i f you are ne w to t he lang uage.

(12)

F i n d m o r e S t a t i o n X C h e a t S h e e t s h e r e -

h t t p s : / / w w w . s t a t i o n x . n e t / c a t e g o r y / c h e a t - s h e e ts / S y m b ol

:

; ,

. ..

~

` `

Qu ic k Re f e r e nce

similar to a NOP – a do not hing operat ion. I t is a shell buil t in w i t h an e x i t s t at us of t r ue

us e d to s eperate commands intende d to r un s e quent all y.

us e d for link ing toge t her ar i t hme t ic operat ions . A ll are e valu t at- e d bu t onl y t he las t is re t ur ne d

repre s ent s t he cur rent dire c tor y.

repre s ent s p arent dire c tor y.

e x p ands to home dire c tor y.

is depre c ate d and should not be us e d. Read f ur t her in i t s re spe c- t i ve s e c t ion.

S y nt a x St r u c t u r e I f

I f- els e

I f- eli f- els e

F or

W hile

Unt il

S ele c t

C as e

A ssoc iate d Key wo r d s o r Key S y m b ol s

if then fi if then else fi if then elif else fi

or do done

w hile do done

unt il do done

s ele c t in do done

c as e ) ;; e s ac

Desc r i pt io n

Te s t a condi t ion.

Te s t a condi t ion and us e a fallb ack i f t he te s t fails .

Prov ide s addi t ional te s t ing plus a fallb ack i f all te s t s fail. You may sk ip t he eli f condi t ions or add as many in - be t we en as you like. Simi - lar l y, you may sk ip t he els e fallb ack .

I terate over a s e quence, a lis t or any t hing as far as t he imag inat ion goe s .

W hile a condi t ion is t r ue - repeat unt il t hat condi t ion is no longer t r ue

T he inver s e of t he w hile loop - as long as t he te s t- command fails , t he unt il - loop cont inue s . S ele c t s ele c t in do done Us e d for eas y menu generat ion. A ny s t atement w i t hin c an be anot her s ele c t cons t r uc t , t hus enabling sub - menu creat ion.

A l ter nat i ve i f- branching. E ach c as e is an e x pre s sion w hich matche s a g i ven p at ter n (i.e., a c as e).

F l o w C o n t r o l

F low cont rol s t r uc t ure s in B ash are s t raig ht for ward , albei t B ash is unfor g i v ing i f you ge t t he s y nt a x w rong.

View examples on how to use control flow in bash.

References

Related documents

(b) Cross sectional HAADF STEM image of the Si-Al interface between the Al and Si. Thus, for lightly doped, p-type Si etched to form an array of Si NWs is best

3. the response y1 is not smooth, indicating inconsistent and attenuated kinetic energy supply to the system. as in the case of a low-pass filter, a band-stop frequency very close

5 and 6, it can be concluded that for stable operation of an MMC-based MTDC controlled by vector current control, one of the AC grids connected to converter

Motivated by the problem of detecting changes in the incidence of terrorism from a global terrorism database, we propose a novel approach to multiple changepoint de- tection

Om politic şi de stiinţă maghiar, Samuel Teleki de Szek s‑a născut în localitatea Dumbrăvioara, comitatul Mureț şi a fost fiul lui Adam Teleki (n. 1780 – d. 1859).. Primele

Explain the following problems and how they can be solved using an enhanced suffix array: longest repeated substring, shortest unique substring, longest common substring, maximal

While Ramesses II was certainly not a typical Egyptian pharaoh, far various reasons we know a great deal about him, and exploring his life in detail should provide readers with

VOSpace UWS SCS SSA SIA TAP UWS SQL Service UWS Public Services Resource Resolver Storage Mgr Query Manager Job Manager Authentication Private Services Ops Monitor Private Repo