!"#$%&'()"*+",(-(./01(
File reading
.?<#line#-+#WH6) (#file.txt"1#:?##
command#
:?+&# # #
O&">(,3&(;*=&(file7=*+&(A8(=*+ & ("+>(&9&#%,&(,3&(
#755"+>B(2#3 4#R&4&(,3&(=*+&(*'( > &;*+ & >(A8(,3& (
HST(G"4*"A=&(P'&&('&#,*7+?'(&+ > QB((T&,(*,(,7(UV+U(
,7(7A,"*+(,3&(A&3"G*74(&96 &#,&> B(
#
[%-7&#<&):#line#1:?### # O&">(,3&(;*=&(file((
command### # =*+&(A8(=*+&("+>#
:?+&#I#file# # ############&9&#%,&(,3&(#755"+>B#
(
\8@AW]4+]# T&,(,3&(\+,&4+"=(8*&=>(@&6"4",74(PHSTQ(
G"4*"A=&(,7(UV+UB(W8(>& ;" %=,(*,'(G"= % & (*' (U(V,V+U(
P'6"#&<(,"A("+>(+&@=*+&QB(
(
Arrays and Hashes
!"#\+:&G&:#)<<) F#,#
(
arrayAH"# 74# #:&67)<&#>)#array#
)&#="4&( "+( *+>&9&>( "44"8( "+>( *+*,*"=*X&( *,( ,7(
A&( &56,8B( H+( ,3&( '+>( #"'&( "+( &9*',*+C(
"44"8(*'(+7,(*+*,*"=*X&>B(
(
arrayAH!++)#K)<#^77)"#
23&("44"8(array(*'(*+*,*"=*X&> (@*,3(,34&&(G" =% & ' B(
#
array/N0=value#
T&,(,3&(&=&5&+,(N(7;(,3&("44"8(array(,7(value7
#
array+=(value1#value2#value3)#
M66&+>(,3&("44"8(@*,3(,34&&(G"=%&'B7
WTarray/N0V#
L96"+>(,3 &( &=&5&+,( 4&;&4&+ #&>( A8( ,3&( *+>&9 (
N(;475 (arrayB(
(
WT_)<<)F/N0V#
T*X&( P',4*+C( =&+C,3Q( 7;( ,3& ( G"=%&( 4&;&4&+#&>(
A8(,3&(*+>&9(N(*+ (array(
(
WT_array/X0V#
T*X&(P+%5A&4(7;(&=&5&+,'Q(7;(arrayB(
#
WT#3array/X0V#
L96"+>( &"#3( array( *+>&9( F& 8 ( "'( "( '&6"4",&(
"4C%5&+,B(
(
WT)<<)F/X0V#
L96"+>("==(,3&(G"=%&'(',74&>(*+(arrayB(
(
B+'&(#9D#array/N0#
)&',478(,3&(array(&=&5&+,(",(*+>&9(NB(
#
B+'&(#9D#array#
)&',478(,3&(#756=&,&(arrayB(
((
O"#!''?6-)(-D&#)<<)F#2#34#8<?*#O)'%#`#2#34,#
#
:&67)<&#>!#array#
( )&#="4&("+("''7#*",*G&("44"8(arrayB(
(
array#AH/string10Avalue1#/string20Avalue2"#
M''*C+( ,@7( G"=%&'( *+( "+ ( "''7#*",*G&( arrayB(
Y7%(5%',(>&#="4&(,3&("''7#*",*G&("44"8(;*4',B(
(
K5*,,*+C( ,3&( "66&+>( #75 5 "+>( PZ[Q<( "==( 7,3&4(
#755"+>'( "4&( '*5*="4( ,7( ,37'&( 7;( *+>&9&>( "44"8B(
L9#&6,( ,3",( ,3&( *+>&9( F&8( *'( +7( 574&( "( +%5&4*#"=(
G"=%&(N(A%,("(@$a\bcB(
Programming in bash
_32d-+2d )' % #
\4*,,&+(",(,3&(,76(7;(87%4('#4*6,<(*,("==7@'(,7(>&;*+&(
,3&('3&==(,7(%'&B(K6,*7+(#"+(A&("> >&> ("'(>G(;74(>&A A % CB(
(
'7&&5#eR # T%'6&+>(&9&#%,*7+(;74("+(*+,&4G"=(7;((]/('+>'B(
(
&G-(# ^%*,(,3&(647C4"5B#
#
U2scriptU'%# #L9&#%,&(,3&('#4*6,(script(P23&(;*=&?'(
&9&#%,*+C(4*C3,(*'(+&&>&>QB(
_#comment(( 23*'(*'("(#755&+,B(
!"#!<=B*&+('##
#
U2scriptU'%#arg1#arg2#
\*,3(,3",(#755"+><(,3&(' # 4* 6 , (4& # & *G&(G"=%& '(
'#4*6,B'3(*+(WR<(arg1(*+(WQ<(arg2(*+(WfB(
W_# 23&(+%5A&4(7;("4C%5&+,'B#
WX# M44"8(7;("4C%5&+,'B#
(
O"#8B+6(-?+'#
#
_(`V(M(;%+#,*7+(5%',(A&(>&;*+&>(A&;74&(,7(#"==(*,B(
(
.B+6(-?+#hello#T#
command##
################V#
)&;*+*,*7+(7;("(;%+#,*7+(#"==&>(helloB(23&(command(@*==(
A&(6&4;745&>(@3&+(,3&(;%+#,*7+(*'(#"==&>B(
(
%&77?#arg1#arg2#
D"==( ,3&( ;%+#,*7+( +"5&>( hello( @*,3( .(
"4C%5&+,'B((
(
2#34 #g-(%-+#.B+6(-?+'h#) <=B*&+('#)<&#(<&)(&:#-+#(%&#')*&#
*)++&<#)'#)<=B*&+('#=-D&+#(?#)#'6<-5(U#
(
i"#^'&<#-+(&<.)6&##
<&):#variable#
\"*,(;74("+(%'&4(*+6%,("+>('"G&(,3&(*,(*+(variableB(
(
?5(-?+'AYopt1#opt2Y#
'&7&6(#?5(#-+#W?5(-?+'1#:?#
-.#/#YW?5(Y#A#Yopt1Y#01#(%&+#
# # command1#
&7-.#/#YW?5(Y#A#Yopt2Y#01#(%&+#
command2#
&7'&#
command3#
.-#
:?+&#
23*'( *' ( "( ,&9 , ( A" '& > ( %' &4 - ;4 *&+ > =8( 5&+%B( H,(
64756,'(,3&(%'&4(;74(&"#3(a76,?(*+(b76,*7+'B(