C O N F I D E N T I A L

UNIX Utilities and Shell
Programming
Brian M. Appold
Director of Design Solutions
US Office – Sunnyvale, CA
October 2!
C O N F I D E N T I A L 2
October 2!
Co"rse Sched"le
"
U#$% Utilities
"
&ednesday, October '(, )*''a+
"
,riday, October '-, )*''a+
"
.uesday, October 2', 2*/p+
"
C S0ell 1rogra++ing
"
&ednesday, October 22, 2*/p+
C O N F I D E N T I A L !
October 2!
Co"rse #oals
"
U#$% co++ands
"
Use wc co++and to count c0aracters, 2ords, 3 lines
"
Use sort co++and to sort files
"
Use find co++ands to locate files
"
Use grep/egrep co++ands to select lines of a file
"
Use sed co++and to edit a file
"
Use awk co++and to create for+atted output fro+ a
structured file
"
C S0ell co++ands
"
4ead user inputs
"
Update a file
"
1erfor+ arit0+etic
"
5ist file contents sorted
"
5ist a file by user specified searc0 pattern
C O N F I D E N T I A L /
October 2!
UNIX Utilities
"
wc co++and
"
sort co++and
"
find co++and
"
S0ell +etac0aracters
"
grep/egrep co++ands
"
4egular e6pression +etac0aracters
"
sed co++and
"
awk co++and
C O N F I D E N T I A L (
October 2!
UNIX Utilities E$ercises
"
76ercise ' – wc, sort, 3 find
"
76ercise 2 – S0ell Metac0aracters
"
76ercise ! – 4egular 76pression
"
76ercise / – 4eg. 76pression Metac0aracters
"
76ercise ( – sed Co++ands
"
76ercise 8 – Multi*line sed Co++ands
"
76ercise - – awk Co++ands
"
76ercise 9 – More awk
C O N F I D E N T I A L 8
October 2!
UNIX Utilities % wc
"
Synta6:
wc ;options< filena+e
"
Options:
*l count lines
*2 count 2ords
=note: spaces and returns define >2ord?@
*c count c0aracters
C O N F I D E N T I A L -
October 2!
UNIX Utilities % wc
"
76a+ples:
A 2c petc0ip
) '( /8 petc0ip
A 2c –l petc0ip
) petc0ip
A 2c –2 petc0ip
'( petc0ip
A 2c –c petc0ip
/8 petc0ip
C O N F I D E N T I A L 9
October 2!
UNIX Utilities % sort
"
Synta6:
sort ;options< ;Bs2;*s2<< filena+e
"
Options:
*tc use >c? as t0e 2ord deli+iter c0aracter
Bs2 0o2 +any fields to sCip over before sorting data
*s2 20ic0 field to stop t0e sorting
*o direct output to t0e file specified
*r reverse t0e current collating seDuence
*n nu+eric collating seDuence
C O N F I D E N T I A L )
October 2!
UNIX Utilities % sort
"
76a+ples:
A sort –t: petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
#ote': default is B for starting field to sort
#ote 2: petc0ip file s0o2n in Appendi6 A
C O N F I D E N T I A L '
October 2!
UNIX Utilities % sort
"
76a+ples:
A sort –t: B8 –- B( –8 petc0ip
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
#ote: if first sort finds duplicate data, t0en data is sorted by ;B( –8<
C O N F I D E N T I A L ''
October 2!
UNIX Utilities % sort
"
76a+ples:
A sort –t: B' *opetc0ip petc0ip
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
#ote: *o option 2rites over e6isting petc0ip file in t0is e6a+ple
C O N F I D E N T I A L '2
October 2!
UNIX Utilities % sort
"
76a+ples:
A sort –t: B'r petc0ip
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
#ote: >sort –r –t: B' petc0ip? 2ill give you t0e sa+e result
C O N F I D E N T I A L '!
October 2!
UNIX Utilities % sort
"
76a+ples:
A sort –n –t: B- petc0ip
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
#ote: #u+eric  ', 2, !, ', 2, K
ASC$$  ', ', 2, 2, !, K
C O N F I D E N T I A L '/
October 2!
UNIX Utilities % find
"
Synta6:
find directory ;ot0er options< ;output options<
"
Output options:
*print print t0e file na+e 20en found
*e6ec c+d runs t0e co++and on file na+e if found
*oC c+d liCe e6ec, but asCs for confir+ation first
*ls s0o2s detailed ls on file na+e if found
C O N F I D E N T I A L '(
October 2!
UNIX Utilities % find
"
Ot0er options:
*na+e fna+e print t0e file na+e 20en found
*siIe n true if file is n blocCs long =('2 bytesFblC@
Bn  +eans L n
n  +eans M n
*n  +eans N n
*per+ onu+ file per+issions +atc0 onu+
onu+  +eans file 0as e6act
per+ission
*onu+  +eans file 0as t0is
per+ission or +ore
*user una+e true if t0e file belongs to t0e user una+e
C O N F I D E N T I A L '8
October 2!
UNIX Utilities % find
"
76a+ples:
A find F2orCingFtraining *print
F2orCingFtrainingFpetc0ip
F2orCingFtrainingFpetc0ipObaCup
F2orCingFtrainingFdataOfile
A find F2orCingFtraining –user brian –ls
28)22 ' *r26r*6r*6 ' brian staff /8 Oct ' ):// F2orCingFtrainingFpetc0ip
28)2! ' *r**r**r** ' brian staff /8 Oct ' ):!' F2orCingFtrainingFpetc0ipObaCup
A find F2orCingFtraining –per+ -(( –ls
28)22 ' *r26r*6r*6 ' brian staff /8 Oct ' ):// F2orCingFtrainingFpetc0ip
28)!) ' *r26r*6r*6 ' Penny staff -/ Sep ! '/:22 F2orCingFtrainingFdataOfile
A find F2orCingFtraining –per+ */// –ls
28)!) ' *r26r*6r*6 ' Penny staff -/ Sep ! '/:22 F2orCingFtrainingFdataOfile
28)22 ' *r26r*6r*6 ' brian staff /8 Oct ' ):// F2orCingFtrainingFpetc0ip
28)2! ' *r**r**r** ' brian staff /8 Oct ' ):!' F2orCingFtrainingFpetc0ipObaCup
C O N F I D E N T I A L '-
October 2!
UNIX Utilities % find
"
76a+ples:
A find F2orCingFtraining –na+e petc0ip –print
F2orCingFtrainingFpetc0ip
A find F2orCingFtraining –na+e Qpetc0ipRS –print
F2orCingFtrainingFpetc0ip
F2orCingFtrainingFpetc0ipObaCup
A find F2orCingFtraining –na+e Qpetc0ipRS –e6ec cp TU Ft+pFbacCup VW
A ls Ft+pFbacCup
petc0ip petc0ipObaCup
A find F2orCingFtraining –siIe B' –e6ec ls –l TU VW
28)!) ' *r26r*6r*6 ' Penny staff -/ Sep ! '/:22 F2orCingFtrainingFdataOfile
#ote: ' blocC M ('2 bytes, ' blocCs M ('2G bytes ='F2 Meg@
C O N F I D E N T I A L '9
October 2!
E$ercise & % wc' sort, ( find
'. ,ind all files in t0e FusrFlib directory and its
subdirectories and print t0eir na+es
Ans2er: A find FusrFlib *print
2. &0at does t0e follo2ing co++and doX
A find Fusr –na+e data –user dave –per+ B/ –print
Ans2er: finds 3 prints file data 2it0 o2ner dave and
per+ission at +ost /
!. &0at does t0e follo2ing co++and doX
A sort –t: *n B! dataOfile
Ans2er: sort t0e /
t0
field of dataOfile in nu+erical order
C O N F I D E N T I A L ')
October 2!
E$ercise & % wc' sort, ( find
/. &0at do t0e follo2ing 2 co++ands doX
'. A find F *siIe ( –e6ec ls –l TU VW
2. A find F *siIe B( –e6ec ls –l TU VW
Ans2er:
'. finds 3 e6ecutes ls –l on files under root M ( blocCs
2. finds 3 e6ecutes ls –l on files under root L ( blocCs
(. &0at does t0e follo2ing co++and doX
A find F *na+e petc0ip –e6ec 2c TU VW
Ans2er: finds 3 e6ecutes 2c on files na+ed petc0ip
under root
C O N F I D E N T I A L 2
October 2!
E$ercise & % wc' sort, ( find
8. &rite a co++and to re+ove all files na+ed core
on t0e syste+. C0ecC for confir+ation before
re+oving.
Ans2er: A find F *na+e core –oC r+ TU VW
-. &rite a co++and to s0o2 t0e nu+ber of lines in
t0e FetcF0osts file.
Ans2er: A 2c –l FetcF0osts
9. &0at field 2ill a B2 sort on 20en using t0e sort
co++andX
Ans2er: !
rd
field
C O N F I D E N T I A L 2'
October 2!
Shell )etacharacters
"
S0ell +etac0aracters are 2ildcards used for file
na+es
R or +ore occurrences of any c0aracter
X Any ' c0aracter
;abc< Single c0aracter +atc0
;a*n< Single c0ar. +atc0, range of c0aracters
C O N F I D E N T I A L 22
October 2!
E$ercise 2 % Shell )etachar*
'. &rite a co++and to list only t0e file na+es t0at are
a '*digit nu+ber.
Ans2er: A ls ;*)<
2. &rite a co++and to list only t0e file na+es t0at are
a !*digit nu+ber.
Ans2er: A ls ;*)< ;*)< ;*)<
!. &rite a co++and to list only t0e file na+es t0at
begin 2it0 a capital letter.
Ans2er: A ls ;A*Y<R
/. &rite a co++and to list only t0e file na+es ending
in a digit.
Ans2er: A ls R;*)<
C O N F I D E N T I A L 2!
October 2!
E$ercise 2 % Shell )etachar*
(. &rite a co++and to list only t0e file na+es ending
in an a, c, or s.
Ans2er: A ls R;acs<
8. &rite a co++and to list only ( c0aracter file
na+es.
Ans2er: A ls XXXXX
-. &rite a co++and to list only t0e file na+es t0at
begin 2it0 . and end 2it0 a digit.
Ans2er: A ls .R;*)<
C O N F I D E N T I A L 2/
October 2!
UNIX Utilities % grep/egrep
"
.0e grep co++and searc0es file=s@ for a given pattern
and prints out t0e lines t0at contain t0e pattern. egrep is
a version of grep t0at recogniIes an e6tended set of
2ildcard c0aracters.
"
Synta6:
grep ;options< regular*e6pression filena+e
"
Options:
*l list only t0e na+es of files 2it0 +atc0ing lines
*i ignore t0e case of letters in +aCing co+parisons
*n precede eac0 line by its relative line Z in t0e file
*v invert searc0, only display lines t0at do not +atc0
*c s0o2 t0e nu+ber of +atc0ing lines
C O N F I D E N T I A L 2(
October 2!
UNIX Utilities % grep/egrep
"
76a+ples:
A grep cat petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
A grep –i ds0 petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
A grep –c dog petc0ip
/
C O N F I D E N T I A L 28
October 2!
UNIX Utilities % grep/egrep
"
76a+ples:
A grep –n dog petc0ip
2:SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
!:Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
/:1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
):S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
A grep –v dog petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
C O N F I D E N T I A L 2-
October 2!
+eg"lar E$,ression
)etacharacters
"
4egular e6pression +etac0aracters are 2ildcards
used to +atc0 file contents
. Any ' c0aracter
[ 7nd of line
\ Beginning of line
V .aCe ne6t ' c0aracter literally
;abc< Single c0aracter +atc0 =i.e. a, b, or c@
;\abc< Single c0aracter not in set =i.e. #O. a, b, or c@
;a*c< Single c0aracter in range =i.e. a t0roug0 c@
C O N F I D E N T I A L 29
October 2!
+eg"lar E$,ression
)etacharacters
"
76a+ples:
A grep Q%[S grepfile
.0is line ends in an %
A grep Q[[S grepfile
.0is line ends in a dollar sign [
A grep Q\S grepfile
\ .0is line begins 2it0 a carat
A grep QV\[S grepfile
.0is line ends in a carat \
#ote: grepfile file is s0o2n in Appendi6 B
C O N F I D E N T I A L 2)
October 2!
+eg"lar E$,ression
)etacharacters
"
76a+ples:
A grep QB;ioa<bS grepfile
Ei, +y na+e is Bob
Ei, +y na+e is Bib
Ei, +y na+e is Babs
A grep QF9.:S grepfile
.0is is a date in t0e eig0ties :9F'!F9/:
A grep Q\[S grepfile  finds blanC lines
C O N F I D E N T I A L !
October 2!
+eg"lar E$,ression )etachar*-
The . Character
"
.0e asterisC special c0aracter represents or +ore
occurrences of t0e previous c0aracter. $t al2ays
functions 2it0 t0e c0aracter preceding it.
aR or +ore occurrences of t0e letter a
;*)<R or +ore occurrences of a nu+eral
;*)<;*)<R A nu+eral follo2ed by or +ore nu+erals
; *<;*)<;*)<R A positive or negative integer
.R or +ore occurrences of any c0aracter
C O N F I D E N T I A L !'
October 2!
+eg"lar E$,ression )etachar-
The . Character
"
76a+ples:
A grep Q:.R;*)<;*)<:S grepfile
.0is is a date in t0e eig0ties :9F'!F9/:
.0is is a date in t0e nineties :-F(F)2:
A grep Q\S.R![S petc0ip
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L !2
October 2!
+eg"lar E$,ression )etachar*-
sed ( grep onl/
"
.0ese regular e6pression +etac0aracters are used
2it0 sed and grep co++ands only.
VTn,+VU Specify t0e nu+ber of occurrences to +atc0
C O N F I D E N T I A L !!
October 2!
+eg"lar E$,ression )etachar*-
sed ( grep onl/
"
76a+ples:
A grep Q:AVT!VU:S grepfile  e6actly ! occurrences
Eere are ! :AAA:s
A grep Q:AVT!,VU:S grepfile  ! or +ore
occurrences
Eere are ! :AAA:s
Eere are ( :AAAAA:s
A grep Q:AVT',!VU:S grepfile  ' to ! occurrences
Eere is an :A:
Eere are ! :AAA:s
#ote: grepfile s0o2n in Appendi6 B
C O N F I D E N T I A L !/
October 2!
+eg"lar E$,ression )etachar*-
awk ( egrep onl/
"
.0ese regular e6pression +etac0aracters are used
2it0 awk and egrep co++ands only.
B ' or +ore occurrences of t0e preceding c0aracter
X or ' occurrences of t0e preceding c0aracter
] logical O4
C O N F I D E N T I A L !(
October 2!
+eg"lar E$,ression )etachar*-
awk ( egrep onl/
"
76a+ples:
A egrep QMilly]S0elbyS petc0ip
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
A egrep Q;*)<BS grepfile
.0is line contains a nu+ber: '2!/
.0is is a date in t0e eig0ties :9F'!F9/:
.0is is a date in t0e nineties :-F(F)2:
Eere are ! :AAA:s
Eere are ( :AAAAA:s
A egrep QF;*)<XFS grepfile
.0is is a date in t0e nineties :-F(F)2:
C O N F I D E N T I A L !8
October 2!
E$ercise ! % +eg"lar
E$,ression )etacharacters
'. 5ist lines 2it0 pet na+e 5ucCy.
Ans2er: A grep QucCyS petc0ip
2. 5ist ani+als 20ose na+e begins 2it0 an O.
Ans2er: A grep Q\OS petc0ip
!. 5ist ani+als 2it0 na+es starting fro+ A to M.
Ans2er: A grep Q\;A*M<S petc0ip
/. 5ist ani+als 2it0 na+es t0at donSt begin 2it0 5.
Ans2er: A grep Q\;<S petc0ip or grep –v QS petc0ip
(. 5ist ani+als born in '))!.
Ans2er: A grep QF'))!:S petc0ip
C O N F I D E N T I A L !-
October 2!
E$ercise ! % +eg"lar
E$,ression )etacharacters
8. 5ist ani+als born in t0e '))Ss.
Ans2er: A grep QF'));*)<:S petc0ip
-. 5ist cats 2it0 pet c0ip nu+bers in t0e / to
/)))) range.
Ans2er: A grep Q:cat:.R:/;*)<VT/VU[S petc0ip
9. 5ist DSE or D5E cats.
Ans2er: A grep Q:cat:D;S5<E:S petc0ip
). 5ist ani+als 20ose na+e are Milly or ,red.
Ans2er: A egrep Q\Milly]\,redS petc0ip
'. 5ist lines 2it0 at least / digit +a6i+u+ cost.
Ans2er: A grep Q:;*)<VT/,VU:S petc0ip
C O N F I D E N T I A L !9
October 2!
UNIX Utilities 0 sed
"
Strea+ editor
"
Synta6:
sed ;*n< –f sedscript filena+e
or
sed ;*n< Qco++andS filena+e
"
Co++ands covered 0ere are:
ssearc0 and replace te6t
d delete lines
pprint lines
i insert lines
aadd lines
cc0ange lines
C O N F I D E N T I A L !)
October 2!
sed- s command
"
1erfor+ searc0 and replace operations 2it0 sed.
$ndicate 20ic0 occurrences of a +atc0 you 2ould liCe
to replace at t0e end of t0e co++and. .o c0ange all
occurrences, use t0e g flag. sed defaults to t0e first
occurrence if you do not specify.
"
Synta6:
sed QsFsearc0*forFreplace*2it0FS filena+e
#ote: t0is for+at 2orCs 2it0 all lines in t0e file filena+e
C O N F I D E N T I A L /
October 2!
sed- s command
"
76a+ples:
A sed QsFcatFfelineFS petc0ip
CorCy =Big Boy@:1eline:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
K
A sed QsFFMFS petc0ip  first occurrence
CorCy =Big Boy@:feline:DSE:!F'9F'))):(2:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F22:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F22':'2:.o+:Hones:)(''-
K
C O N F I D E N T I A L /'
October 2!
sed- s command
"
76a+ples:
A sed QsFFMFgS petc0ip  all occurrences
CorCy =Big Boy@:feline:DSE:!F'9F'))):(22:,red:S+it0:)(M!(
SpunCy:dog:Jer+an S0eppard:8F'(F2222:-22:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F222':'222:.o+:Hones:)(''-
K
A sed QsFFMF2S petc0ip  2
nd
occurrence
CorCy =Big Boy@:feline:DSE:!F'9F'))):(2:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F22:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F22':'2:.o+:Hones:)(''-
K
C O N F I D E N T I A L /2
October 2!
sed- 0n o,tion
"
By default, sed prints all t0e lines in your file. .0e –n
option along 2it0 t0e p co++and prints only t0e lines
t0at are affected by t0e co++and
"
Synta6:
sed –n Qco++andFpS filena+e
C O N F I D E N T I A L /!
October 2!
sed- 0n o,tion
"
76a+ples:
A sed QsFdogFDogFS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:Dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:Dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:Dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
K
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:Dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
A sed –n QsFdogFDogFpS petc0ip
SpunCy:Dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:Dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:Dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
S0elby:Dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L //
October 2!
3or4ing on a S"bset o1 Lines
"
By default, sed operates on all t0e lines in your file.
Eo2ever, you can 2orC on a subset of lines in your file
by specifying a range of line.
"
Synta6:
sed Qstart*line,finis0*line;^<co++andS filena+e
sed QFpatternF;^<co++andS filena+e
sed Qline*nu+ber;^<co++andS filena+e
C O N F I D E N T I A L /(
October 2!
+ange o1 Line N"mbers
"
76a+ples:
A sed Q!,(sFcatFCatFS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Milly:Cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L /8
October 2!
+ange o1 Line N"mbers
"
76a+ples:
A sed –n Q!,(sFcatFCatFpS petc0ip
Milly:Cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
A sed Q2,/pS petc0ip
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
C O N F I D E N T I A L /-
October 2!
+ange o1 Lines 5ased U,on
)atching
"
76a+ples:
A sed –n QFOtisF,F5ucCyFpS petc0ip
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
A sed QFS+it0F,FGennedyFdS petc0ip
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L /9
October 2!
S"bset o1 Lines 0 6ariations
"
76a+ples:
A sed –n Q8,FferretFpS petc0ip
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
A sed –n Q8pS petc0ip
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
A sed –n QFferretFpS petc0ip
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
C O N F I D E N T I A L /)
October 2!
S"bset o1 Lines 0 6ariations
"
76a+ples:
A sed –n QFOtisFsF!F'2FpS petc0ip
Otis:cat:DSE:'F2F22:&2:Ben:Stiller:/9-!/
A sed –n Q[pS petc0ip
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
A sed –n Q2,-^pS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L (
October 2!
sed- The 789 Character
"
$f you are searc0ing for a slas0 c0aracter =F@, you +ust
precede it 2it0 a bacCslas0 c0aracter =V@.
A sed QsF:Fcs0F:F___FgS Ft+pFpass2d
"
.0e sed co++and allo2s you to use an alternative
c0aracter to t0e slas0 in t0e searc0 and replace
operations. &0atever c0aracter follo2s t0e s
co++and is interpreted as t0e separator bet2een t0e
search-for and replace-with sections of t0e co++and.
.0is is useful 20en you 0ave slas0es in t0ese
sections.
A sed QsBFcs0BF___BgS Ft+pFpass2d
C O N F I D E N T I A L ('
October 2!
Search ( +e,lace 3ildcards
"
&ildcard c0aracters used 2it0 sed search-for and
replace-with operations:
searc0*for replace*2it0
[ 7nd of line3 +atc0ed pattern
\ Beginning of line
. Any single c0aracter
R or +ore occurrences
of previous c0aracter
VN VL 2ord
;abc< Single c0ar. +atc0
;\abc< Single c0ar. not in set
;a*c<Single c0ar. in range
V= V@ set up variable V' V2 etc. value of variable
#ote: +ost special c0aracters in t0e searc0*for section 0ave no special +eaning in t0e replace*
2it0 section
C O N F I D E N T I A L (2
October 2!
Search ( +e,lace 3ildcards
"
76a+ples:
A sed QsFD.EF3 BreedFS petc0ip
CorCy =Big Boy@:cat:DSE 5reed:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Milly:cat:DSE 5reed:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE 5reed:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E 5reed:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L (!
October 2!
Search ( +e,lace 3ildcards
"
76a+ples:
A sed QsFV=K..V@[F$D*V'FS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:ID0)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:ID0)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:ID0)(''-
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:ID0)/98
Milly:cat:DSE:'F2F22:!:Betty:S+it0:ID0)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:ID0/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:ID0/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:ID0)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:ID09(82!
C O N F I D E N T I A L (/
October 2!
Search ( +e,lace 3ildcards
"
76a+ples:
A sed QsM:V='VT,'VU;*)<V@FV=;*)<VT',2VUV@FM:V2FV'FMS petc0ip
CorCy =Big Boy@:cat:DSE:&;8!8'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:&<8=82:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:2!8>82':'2:.o+:Hones:)(''-
1retIel:dog:.errier Mi6:!8>8'))8:(:5ena:Eatc0er:)/98
Milly:cat:DSE:28&822:!:Betty:S+it0:)/(!)
Otis:cat:DSE:28&822:!:Ben:Stiller:/9-!/
,red:ferret::?8&282':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:2&8<8'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:!8@822:'2:Diane:5ee:9(82!
C O N F I D E N T I A L ((
October 2!
Search ( +e,lace 3ildcards
"
76a+ples:
A sed QsFVNdogVLFcanineFS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:canine:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:canine:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
Eotdoggie:canine:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:canine:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
#ote: all dogs c0anged to canine, but t0e dog Eotdoggie is not a 2ord, so no c0ange
C O N F I D E N T I A L (8
October 2!
E$ercise ? % sed Commands
'. &rite a sed co+and to list lines (*' of petc0ip.
Ans2er: A sed –n Q(,'pS petc0ip
2. &rite a sed co+and to delete t0e last line of
petc0ip.
Ans2er: A sed Q[dS petc0ip
!. 5ist only lines containing capital M in petc0ip.
Ans2er: A sed –n QFMFpS petc0ip
/. C0ange ,red S+it0 to Hane S+it0 in petc0ip.
Ans2er: A sed –n QsF,red:S+it0FHane:S+it0FgpS petc0ip
(. 5ist Maggy t0roug0 5ucCy in petc0ip.
Ans2er: A sed –n QF\MaggyF,FucCyFpS petc0ip
C O N F I D E N T I A L (-
October 2!
sed- The 7A9 Character
"
$n sed co++ands, t0e dollar sign c0aracter =[@ +ay
stand for t0e last line of t0e file, a literal dollar sign, or
t0e end of a line. Eere is a su++ary of t0e dollar sign
c0aracter +eanings
'. .0e [ 0as no special +eaning inside t0e ; < notation
A sed QF/(;2!/[<FdS petc0ip
2. &0en specifying line nu+bers, t0e dollar sign is a
sy+bol for t0e last line in t0e file
A sed –n Q(,[pS petc0ip  print line ( to 7O,
A sed –n Q[pS petc0ip  print last line of file
C O N F I D E N T I A L (9
October 2!
sed- The 7A9 Character
!. &0en specifying a range of lines t0roug0 a
pattern +atc0, t0e [ is a sy+bol for t0e end of a
line
A sed –n QF;2!/<[FpS petc0ip
"
&0en perfor+ing a searc0 and replace operation,
t0e dollar sign stands for t0e end of t0e line. But it
is only +eaningful as t0e last c0aracter in t0e
searc0 portion of t0is operation
A sed QsF;2!/<[F(FpS petc0ip
C O N F I D E N T I A L ()
October 2!
E$ercise < % Dollar Sign
5abel all t0e dollar signs as ' of t0ese ! values
'. [ M t0e last line of t0e file
2. [ M a literal [
!. [ M t0e end of t0e line
sed Q',[sFabc[F[abcFgS filena+e

\!
sed QFalp0a[F,Fo+ega[FsFabc[F[abcFgS filena+e
\! \! \!
sed QsFab;c[<Fab6[FgS filena+e

sed QF[[FdS filena+e
\!
C O N F I D E N T I A L 8
October 2!
sed- insert ( add Commands
"
insert and add are +ulti*line co++ands. .0ey reDuire a
bacCslas0 =V@ at t0e end of eac0 line in order to continue t0e
co++and.
"
$nsert =insert before t0e line specified@
A cat sedfile'
'iV
.0is is a ne2 line
A sed –f sedfile' petc0ip
This is a neB line
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
K
C O N F I D E N T I A L 8'
October 2!
sed- insert and add Commands
"
Add =add after t0e line specified@
A cat sedfile2
Z .0is is a co++ent
'aV
.0is is a ne2 lineV
And so is t0is
A sed –f sedfile2 petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
This is a neB line
And so is this
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
K
C O N F I D E N T I A L 82
October 2!
sed- insert and add Commands
"
$nsert before eac0 line starting 2it0 M
A cat sedfile!
F\MFiV
.0is is a ne2 line
A sed –f sedfile! petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
This is a neB line
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
This is a neB line
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
K
C O N F I D E N T I A L 8!
October 2!
sed- Command Files
"
.0e first line of te6t in t0e data file is processed t0roug0
all t0e sed co++ands you list in your sed instruction
file. .0en, t0e ne6t line is processed, and so on
C O N F I D E N T I A L 8/
October 2!
sed- Command Files
A cat sedfile/
'iV
.0is file is petc0ip
FMaggyFcV
Maggy is lost^
FCorCyFsFcatFdogF
A sed –f sedfile/ petc0ip
This 1ile is ,etchi,
CorCy =Big Boy@:dog:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
)agg/ is lostC
1retel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
K
C O N F I D E N T I A L 8(
October 2!
sed- Command Files
A cat sedfile(
F\MFiV
.0is is before t0e M line
F\MFd
A sed –f sedfile( petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
This is be1ore the ) line
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
This is be1ore the ) line
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L 88
October 2!
sed- Command Files
A cat sedfile(
F\MFd
F\MFiV
.0is is before t0e M line
A sed –f sedfile( petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
#ote: order of co++ands +atters^
C O N F I D E N T I A L 8-
October 2!
sed- Carriage Returns
"
At ti+es you 2ill 2ant to insert a carriage return into
your sed replace-with section or searc0 for a carriage
return in t0e search-for section of a sed co++and.
"
$nsert a carriage return in t0e replace section of a
sed co++and. $n t0e replace-with section of t0e
co++and, use a bacCslas0 c0aracter =V@, t0en type
in t0e carriage return. Continue your co++and on
t0e ne6t line.
C O N F I D E N T I A L 89
October 2!
sed- Carriage Returns
A cat file'
sysad+in: sysad+
training: Pane,arc0ie,peggy,PacC
acct: nelson,+iller,+oore,rand
A cat sedfile(
sF:.RF:V
Fg
sF,FV
Fg
C O N F I D E N T I A L 8)
October 2!
sed- Carriage Returns
A sed –f sedfile( file'
sysad+in:
sysad+
training:
Pane
arc0ie
peggy
PacC
acct:
nelson
+iller
+oore
rand
C O N F I D E N T I A L -
October 2!
E$ercise = % )"lti0Line sed
Commands
'. &rite a sed file to c0ange petc0ip as follo2s
a. Add a ne2 line to t0e botto+ of t0e file
Eotdoggie:dog:C0o2:2F2F')98:/:Ho0n:Si+s:/-/2'
b. C0ange Maggy fro+ a 5ab Mi6 to a Springer
Spaniel
Ans2er:
[aV
Eotdoggie:dog:C0o2:2F2F')98:/:Ho0n:Si+s:/-/2'
F\MaggyFsF5ab Mi6FSpringer SpanielF
C O N F I D E N T I A L -'
October 2!
E$ercise = % )"lti0Line sed
Commands
2. &rite a sed file to c0ange petc0ip as follo2s
a. Add >CA? to t0e end of all lines
b. 5ooC for DSE, c0ange to >Do+estic S0ort Eair?
c. Delete all ferrets
Ans2er:
sF[F:CAF
sF:DSE:F:Do+estic S0ort Eair:F
F:ferret:Fd
C O N F I D E N T I A L -2
October 2!
UNIX Utilities 0 awk
"
awk processes structured files. $t assu+es you 0ave
colu+ns and ro2s. .0ere is a version of awk called
nawk 20ic0 includes t0e ability to create functions 2it0in
your co++ands. nawk 2ill not be covered 0ere, but you
are encouraged to follo2*up on your o2n. awk uses
egrep*liCe regular e6pressions.
"
Synta6:
awk –f progra+*file filena+e
or
awk Qprogra+S filena+e
C O N F I D E N T I A L -!
October 2!
awk % 5asic Commands
A a2C –,: QTprint [',[2,[!,[/US petc0ip
CorCy =Big Boy@ cat DSE !F'9F')))
SpunCy dog Jer+an S0eppard 8F'(F2
Maggy dog 5ab Mi6 )F2!F2'
1retIel dog .errier Mi6 )F!F'))8
Milly cat DSE 'F2F22
Otis cat DSE 'F2F22
,red ferret '2F/F2'
5ucCy cat D5E (F2'F'))(
S0elby dog Jolden 4etriever -F!F22
#ote: .0e [', [2, etc. represent t0e fields in eac0 line. .0e co++a prints a
space. .0e –, option defines t0e field separator c0aracter =space by default@.
C O N F I D E N T I A L -/
October 2!
awk % 5asic Commands
A cat a2C'
Tprint [',[2,[!,[/U
Tprint [(,[8,[-U
Tprint >?U
A a2C –,: *f a2C' petc0ip
CorCy =Big Boy@ cat DSE !F'9F')))
( ,red S+it0
SpunCy dog Jer+an S0eppard 8F'(F2
- Gi+ 4eed
Maggy dog 5ab Mi6 )F2!F2'
'2 .o+ Hones
K
C O N F I D E N T I A L -(
October 2!
awk % C"rl/ 5races
"
`ou +ay include +ultiple co++ands inside t0e curly
braces. 1ut a carriage return after eac0 co++and, or else
separate t0e co++ands 2it0 se+icolons.
Tprint [',[2,[!,[/
print [(,[8,[-
print >?U
Tprint [',[2,[!,[/W print [(,[8,[-W print >?U
T
print [',[2,[!,[/
print [(,[8,[-
print >?
U
C O N F I D E N T I A L -8
October 2!
awk % Printing +et"rns ( Tabs
"
Use Vn to print a carriage return, and Vt to print a tab.
A cat a2C2
Tprint [',[2,[!,[/ >Vn? [(,[8,[- >Vn?U
A a2C –,: *f a2C2 petc0ip
CorCy =Big Boy@ cat DSE !F'9F')))
( ,red S+it0
SpunCy dog Jer+an S0eppard 8F'(F2
- Gi+ 4eed
Maggy dog 5ab Mi6 )F2!F2'
'2 .o+ Hones
K
C O N F I D E N T I A L --
October 2!
awk % Processing a S"bset o1
+oBs Using Strings
"
A subset of t0e ro2s of t0e files are processed by using a
string searc0 before t0e curly braces.
"
String aalues
Fregular*e6pressionF
field b Fregular*e6pressionF
^ Fregular*e6pressionF
field ^b Fregular e6pressionF
"
Boolean aalues
]] logical O4
33 logical A#D
C O N F I D E N T I A L -9
October 2!
awk % Processing a S"bset o1
+oBs Using Strings
"
76a+ples:
A a2C –,: QF5enaF Tprint [8,[-,[(US petc0ip
5ena Eatc0er (
A a2C –,: Q['bFMillyF Tprint [',[2,[!,[/US petc0ip
Milly cat DSE 'F2F22
A a2C –,: Q['bF\MF 33 ['bFy[F Tprint [',[(US petc0ip
Maggy '2
Milly !
C O N F I D E N T I A L -)
October 2!
awk % Processing a S"bset o1
+oBs Using N"meric 6al"es
"
A subset of t0e ro2s of t0e files are processed by using a
nu+eric searc0 before t0e curly braces.
"
#u+eric aalues
field MM value
field ^M value
field L value
field LM value
field N value
field NM value
C O N F I D E N T I A L 9
October 2!
awk % Processing a S"bset o1
+oBs Using N"meric 6al"es
"
76a+ples:
A a2C –,: Q[( N / Tprint [8,[-,[(US petc0ip
Betty S+it0 !
Ben Stiller !
Brian Gennedy '
A a2C –,: Q[( MM '2 Tprint [8,[-,[(US petc0ip
.o+ Hones '2
Diane 5ee '2
A a2C –,: Q[( L ( 33 [( N ' Tprint [',[(US petc0ip
SpunCy -
C O N F I D E N T I A L 9'
October 2!
awk % Processing a S"bset o1
+oBs Bith )"lti,le Searches
A cat a2C!
[2bFcatF Tprint >VtBuy so+e cat food for > ['U
[2bFdogF Tprint >VtBuy so+e dog food for > ['U
[2bFferretF Tprint >VtBuy so+e ferret food for > ['U
A a2C –,: *f a2C! petc0ip
Buy so+e cat food for CorCy =Big Boy@
Buy so+e dog food for SpunCy
Buy so+e dog food for Maggy
Buy so+e dog food for 1retIel
Buy so+e cat food for Milly
K
C O N F I D E N T I A L 92
October 2!
E$ercise @ % awk Commands
4efer to t0e file in Appendi6 C, 2rite an awk co++and to:
'. 1rint a list of parties contained in t0e file c0ecCing
Ans2er: a2C –,: QTprint [!US c0ecCing
2. 1rint a list of parties and ite+ nu+bers for ite+s 2ritten
in ,ebruary
Ans2er: a2C –,: Q[2bFVFF Tprint [!,['US c0ecCing
!. 1rint t0e nu+bers for c0ecCs 2ritten for +ore t0at ['
Ans2er: a2C –,: Q['^bF\;Dd<F 33 [/ L ' Tprint ['US c0ecCing
/. 1rint t0e dates and parties for all deposits
Ans2er: a2C –,: Q['bF\DF Tprint [2,[!US c0ecCing
C O N F I D E N T I A L 9!
October 2!
awk % 5E#IN ( END Sections
"
`ou +ay add a B7J$# or 7#D section to your awk script
in order to process infor+ation before or after any ro2s
are processed.
A cat a2C/
B7J$# Tprint >1artyVtVtC0ecC A+ount?U
['bF\;*)<F Tprint [! >Vt? [/U
A a2C –,: *f a2C/ c0ecCing
1arty C0ecC A+ount
A+er. 76press 2/!.
CitibanC aisa '/.)9
1ac. Jas37lec. !).-
1acific Bell 8(.((
C O N F I D E N T I A L 9/
October 2!
awk % 6ariables
"
Any 2ord t0at is not a Cey 2ord 2ill be considered a
variable na+e by awk. awk does contain so+e
variables t0at it Ceeps tracC of auto+atically.
"
awk aariables
,$57#AM7 na+e of t0e data file
,S field separator, defaults to spaces
#, nu+ber of fields in current record
#4 nu+ber of t0e current record =i.e. line Z@
O,S output field separator, represented
by a co++a in print state+ents, defaults
to a space
C O N F I D E N T I A L 9(
October 2!
awk % 6ariables
"
76a+ples:
A a2C –,: Q#4 LM ! 33 #4 NM ( Tprint [8,[-US petc0ip
.o+ Hones
5ena Eatc0er
Betty S+it0
A a2C –,: Q7#D Tprint >.0ere are >#4? records in >,$57#AM7US petc0ip
.0ere are ) records in petc0ip
C O N F I D E N T I A L 98
October 2!
awk % 6ariables
"
76a+ples:
A cat lo2cost
B7J$# T,SM>:?WO,SM>K?U
[( N / Tprint [8,[-,[(U
A a2C –f lo2cost petc0ip
BettyKS+it0K!
BenKStillerK!
BrianKGennedyK'
C O N F I D E N T I A L 9-
October 2!
awk % User De1ined 6ariables
"
aariables can be user defined.
A cat a2C8
B7J$# T
,SM>:?
totalM
U
['bF\DF TtotalMtotalB[/U
['bF\;*)<F TtotalMtotal*[/U
7#D Tprint >Balance is: > totalU
A a2C –f a2C8 c0ecCing
Balance is: '/'(./
C O N F I D E N T I A L 99
October 2!
awk % Arithmetic
"
awk can be used to perfor+ arit0+etic operations.
"
Su++ary
B * R F standard arit0+etic
A re+ainder
BB add '
** subtract '
C O N F I D E N T I A L 9)
October 2!
awk % Standard Arithmetic
"
Addition
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint ['B[!US
!(('2.(/!
"
Division and Multiplication
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint ['F[!US
.!!92!
A ec0o S'2 ./(8- !((.(/! .!/-S ] a2C QTprint [2R[/US
.'(9/-(
C O N F I D E N T I A L )
October 2!
awk % +emainder Arithmetic
"
4e+ainder
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [2A2US
'.(
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint ['A2US

A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [/A2US

A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [!A2US
.(/!
C O N F I D E N T I A L )'
October 2!
awk % Add8S"btract & Arithmetic
"
Add one or subtract one
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint BB[/US
!(
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [/BBUS
!/
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint **[/US
!!
C O N F I D E N T I A L )2
October 2!
E$ercise ; % )ore awk
4eferring to t0e petc0ip file, 2rite an awk co++and to:
'. Jive a total of all t0e +a6i+u+ a+ounts o2ners are
2illing to pay for e+ergency services
Ans2er:
B7J$# T
,SM>:?
totalM
U
TtotalMtotalB[(U
7#D Tprint >.otal for e+ergency service: > totalU
2. &rite a co++and to +ultiply t0e nu+ber (8.)- by
(/.!.
Ans2er: ec0o S(8.)- (/.!S ] a2C QTprint ['R[2US
C O N F I D E N T I A L )!
October 2!
E$ercise ; % )ore awk
!. 1rint a c0art of pet na+es, species, and id nu+bers.
1ut 0eaders on t0e output data. 1rint a total
nu+ber of pets at t0e botto+ of t0e c0art.
Ans2er:
B7J$# Tprint >#a+eVtVtSpeciesVt$D?U
Tprint ['?Vt??Vt?[2?Vt?[9U
7#D Tprint >.otal nu+ber of pets: >#4U
/. 5ist lines (*'
Ans2er: a2C –,: Q#4 LM ( 33 #4 NM ' Tprint [US petc0ip
(. 5ist ani+als 20ose o2ners are 2illing to pay LM
[',. on +edical costs.
Ans2er: a2C –,: Q[( LM ' Tprint ['US petc0ip
C O N F I D E N T I A L )/
October 2!
awk % F"nctions
"
awk co+es 2it0 so+e built*in functions. Eere are a
select fe2:
"
split taCes a string and inserts itSs fields into an array
split=string, array, field*separator@
"
substr e6tracts a set of c0aracters out of a string
substr=string, start*position, +a6*lengt0@
"
lengt0 returns t0e nu+ber of c0aracters in a string
lengt0=string@
C O N F I D E N T I A L )(
October 2!
awk % F"nctions
"
76a+ples:
Use substr to s0orten t0e data output
T
petna+e M substr=[',',(@
print petna+e >Vt? [(
U
C O N F I D E N T I A L )8
October 2!
awk % F"nctions
"
76a+ples:
Use lengt0 to deter+ine t0e data output
$f =lengt0=['@ L (@
T
petna+e M substr=[',',(@
print petna+e >Vt? [(
U
else
Tprint [' >Vt? [(U
C O N F I D E N T I A L )-
October 2!
C Shell Programming
"
Uses of t0e C s0ell
"
4unning C s0ell scripts
"
5ocal variables
"
Obtaining user input
"
cuoting
"
Using s0ell variables in awk and sed
"
C s0ell redirection – input, output, 3 error +essages
"
.0e if state+ent
"
Co++and line input
"
C s0ell arit0+etic
"
.0e while loop
"
.0e foreach loop
"
.0e switch state+ent
"
Jlobal variables
"
.0e break and continue state+ents
"
76it status
C O N F I D E N T I A L )9
October 2!
C Shell E$ercises
"
76ercise ) – &riting a Si+ple C S0ell Script
"
76ercise ' – cuoting
"
76ercise '' – 4edirection
"
76ercise '2 – .rueF,alse Operators
"
76ercise '! – Co++and 5ine Argu+ents
C O N F I D E N T I A L ))
October 2!
C Shell % Uses o1 the C Shell
"
.0e C s0ell can be used as a co++and interpreter
or a progra++ing language. $n t0is training, t0e
focus is on t0e progra++ing aspects of t0e C s0ell.
"
A co++and interpreter
A ls
file'file2 file!
"
A progra++ing language
A cat firstscript
Z^ FbinFcs0
Z .0is is a co++ent
7c0o >.0is is +y first C s0ell script?
A firstscript
.0is is +y first C s0ell script
C O N F I D E N T I A L '
October 2!
C Shell % +"nning C Shell
Scri,ts
.0ere are ! 2ays to run a C s0ell script:
'. Use t0e source co++and. .0is runs t0e script
co++ands in t0e current s0ell.
A source +yscript
2. .ype in t0e script na+e at t0e pro+pt. .0is starts up
a sub*s0ell in 20ic0 to run t0e +yscript co++ands.
A +yscript
!. 1recede t0e script na+e 2it0 FbinFcs0. .0is starts
up a sub*s0ell in 20ic0 to run +yscript co++ands.
A FbinFcs0 +yscript
#ote: you +ust 0ave read 3 e6ecute per+issions to use tec0niDue 2,
read per+ission to use tec0niDue ' or !
C O N F I D E N T I A L ''
October 2!
C Shell % Local 6ariables
"
5ocal variables:
"
Created 2it0 t0e set co++and
"
aisible only to your current s0ell
"
Use set co++and to see all local variables
"
76a+ples:
A set abc M >'2!?
ec0o [abc
'2!
C O N F I D E N T I A L '2
October 2!
C Shell % Local 6ariables
"
76a+ples:
A set
c2d F2orCingFtraining
0istory 2
0o+e Fe6portF0o+eF
noclobber
pat0 =FusrFbin usrFlocalFbin Fe6portF0o+eFbin .@
pro+pt A
s0ell FbinFcs0
abc '2!
C O N F I D E N T I A L '!
October 2!
C Shell % Local 6ariables
"
$f t0ere is any roo+ for confusion, use curly braces
around your variable na+e.
"
76a+ple:
A ec0o [TabcU/(8
'2!/(8
C O N F I D E N T I A L '/
October 2!
C Shell % Obtaining User In,"t
"
Obtaining user input interactively, 20ile t0e script is
running.
A cat +yscript
Z^ FbinFcs0
ec0o –n >$nput a value: >
set na+e M [N
ec0o [na+e
A +yscript
$nput a value: &2!?<
'2!/(
C O N F I D E N T I A L '(
October 2!
E$ercise > % 3riting a Sim,le C
Shell Scri,t
&rite a script t0at prints options for t0e user on t0e
screen per follo2ing instructions:
'. $nclude Z^ FbinFcs0 on your first line
2. $nclude co++ents at t0e top of your script after
t0e first line. $nclude your na+e, t0e script
na+e, a description of 20at t0e script does, and
t0e last date you updated t0e script. .0is is a
good 0abit to develop.
C O N F I D E N T I A L '8
October 2!
E$ercise > % 3riting a Sim,le C
Shell Scri,t
!. Eave your script ec0o t0e follo2ing to t0e user:
C0ecCing
'. Add a c0ecC or deposit
2. 4e+ove a c0ecC or deposit
!. Calculate Balance
C0oose an Option:
/. 4ead t0e userSs response into a variable.
C O N F I D E N T I A L '-
October 2!
E$ercise > % 3riting a Sim,le C
Shell Scri,t
Ans2er:
Z^ FbinFcs0
Z Brian M. Appold
Z c0ecCing.cs0
Z .0is script +anages a c0ecCing account
Z 5ast updated: Oct '! 2!
ec0o >C0ecCing?
ec0o >?
ec0o >'. Add a c0ecC or deposit?
ec0o >2. 4e+ove a c0ecC or deposit?
ec0o >!. Calculate Balance?
ec0o >?
ec0o –n >C0oose and Option: >
set c0oice M [N
C O N F I D E N T I A L '9
October 2!
C Shell 0 D"oting
"
cuoting
Q Duotes everyt0ing e6cept ^
> Duotes everyt0ing e6cept ^, d, and [
d run co++and first, insert output into
surrounding co++and
V Duotes ne6t ' c0aracter =including ^@
C O N F I D E N T I A L ')
October 2!
C Shell 0 D"oting
"
76a+ples:
"
Set*up variable
A set var' M >abc?
"
Double Duotes donSt Duote [, single Duotes do
A ec0o Q[var'S  [var'
A ec0o >[var'?  abc
"
.0e bacC Duote c0aracter is different t0an single
Duote c0aracter
A ec0o ddated  Sun #ov '2 22:!:!- 1S. '))(
C O N F I D E N T I A L ''
October 2!
C Shell 0 D"oting
"
#eit0er single or double Duotes 2orC on t0e ^
C0aracter. Only t0e bacCslas0 2ill 2orC.
A ec0o 0ello^t0ere
t0ere: 7vent not found
A ec0o >0ello^t0ere?
Un+atc0ed >.
A ec0o Q0ello^t0ereS
Un+atc0ed Q.
A ec0o 0elloV^t0ere
0ello^t0ere
C O N F I D E N T I A L '''
October 2!
C Shell 0 D"oting
"
Single and double Duotes bot0 protect t0e
bacCslas0 c0aracter = V @.
A ec0o Vvar'  var'
A ec0o QV[var'S  V[var'
A ec0o >V[var'?  Vabc
C O N F I D E N T I A L ''2
October 2!
C Shell % Using Shell 6ariables
in sed and awk
"
$n +ost cases, you can use a s0ell variable by ending your
single Duoted string rig0t before t0e variable, t0en start it up
again rig0t after.
"
76a+ple:
A set lineno M 2
A a2C Q#4MM',#4MMQ[linenoS Tprint [US petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
A sed –n Q',S[linenoSpS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
C O N F I D E N T I A L ''!
October 2!
C Shell % Using Shell 6ariables
in sed and awk
"
Eo2ever, if your variable is a string containing spaces,
you +ust include double Duotes around t0e variable.
"
76a+ple:
A set na+e M QBig BoyS
A a2C –,: QFS?[na+e?SF Tprint [US petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
A sed –n QFS?[na+e?SFpS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
C O N F I D E N T I A L ''/
October 2!
C Shell % Using Shell 6ariables
in sed and awk
"
,or awk: $f your variable is a string containing spaces
and you are inside a print state+ent, t0en synta6 is +ore
co+ple6. $nclude one double Duote rig0t before your first
single Duoted string ends, and one rig0t after your
second single Duoted string begins.
"
76a+ple:
A set +ypet M >`our ani+alSs na+e is >
A a2C –,: QTprint >S?[+ypet?S? ['US petc0ip
`our ani+alSs na+e is CorCy =Big Boy@
`our ani+alSs na+e is SpunCy
K
#ote: t0is breaCs into ! pieces QTprint >S >[+ypet? Q? ['US
C O N F I D E N T I A L ''(
October 2!
E$ercise & % D"oting
'. &rite a sed co++and to list lines containing t0e
string stored in t0e variable [petna+e.
Ans2er: sed –n QFS?[petna+e?SFpS petc0ip
2. &rite an awk co++and to list t0e na+es of pets
20ose +a6i+u+ e+ergency costs can e6ceed t0e
value stored in [+a6a+ount.
Ans2er: a2C –,: Q[( LS?[+a6a+ount?S Tprint ['US petc0ip
C O N F I D E N T I A L ''8
October 2!
C Shell 0 +edirection
"
4edirecting output
L redirect output
L3 redirect output and errors
LL append
LL3 append output and errors
] pipe
"
.o prevent accidentally over*2riting files 2it0
redirection, set noclobber. .o over*ride noclobber,
use an e6cla+ation point =^@
L^ or L3^
C O N F I D E N T I A L ''-
October 2!
C Shell 0 +edirection
"
$f noclobber is set, t0e append sy+bol 2ill only append
to t0e end of an e6isting file. `ou need to use an
e6cla+ation point if you 2ant it to create t0e file.
LL^
LL3^
"
Multiple co++and redirection
A ls W date W 20o L outfile
A =ls W date W 20o@ L outfile
A =ls bananas L outfile@ L3 errfile
"
4edirection input
N
C O N F I D E N T I A L ''9
October 2!
C Shell 0 +edirection
"
#ote: &0en t0e s0ell sees t0e redirection sy+bol =L
or L3@, t0e s0ell Ieros out t0e file being 2ritten to if it
e6ists, or creates an e+pty file if it does not. `ouSll
notice t0is 20en:
'. `our interrupt a progra+ 2it0 \C before any output is
generated – t0e e+pty file gets created
2. `ou >sort abc L abc? .0e file abc is Ieroed out before
being sorted. `ou inadvertently erase your file.
C O N F I D E N T I A L '')
October 2!
E$ercise && % +edirection
Ans2er t0e follo2ing Duestions for eac0 of t0e
e6a+ples belo2. &0at files are created by t0e
co++and, and 20at infor+ation is stored in eac0 fileX
'. A =ls L outfile8@ L3 outfile -
Ans2er: outfile8 created, contains ls output
outfile- created, contains errors
2. A ==ls W date W 20o@ L outfile9@ L3 outfile)
Ans2er: outfile9 created, contains output of ls, date,
and 20o co++ands
outfile) created, contains errors
C O N F I D E N T I A L '2
October 2!
E$ercise && % +edirection
!. &0at is t0e difference bet2een t0e follo2ing 2
co++andsX
A ls L +ore
A ls ] +ore
Ans2er: '
st
– 2rites to file +ore
2
nd
– pipe ls output to +ore
/. &0at 2ill 0appen if you run t0is co++andX
A sort +yfile L^ +yfile
Ans2er: get an e+pty file, +yfile gets erased
C O N F I D E N T I A L '2'
October 2!
E$ercise && % +edirection
(. &0y +ig0t you set up a co++and t0is 2ayX
A =find F *na+e abc –print L abc.out@ L3 FdevFnull
Ans2er: errors go to a >blacC 0ole?
8. &0at does t0is co++and doX
A =find F *na+e abc –print L QttyS@ L3 FdevFnull
Ans2er: output goes to tty =ter+inal nu+ber@
errors go to >blacC 0ole?
C O N F I D E N T I A L '22
October 2!
C Shell % The if Statement
"
Use an if state+ent to perfor+ an operation if a
value is >true?. ,or t0e C s0ell if state+ent, true
+eans ' =i.e. non*Iero@ and false +eans .
"
Synta6
if = [var MM '(@ t0en
ec0o >eureCa?
endif
C O N F I D E N T I A L '2!
October 2!
C Shell % The if Statement
if ='@ t0en
ec0o >t0is is true?
else
ec0o >t0is is false?
endif
#ote:
then +ust be on t0e sa+e line as if, or else use a bacCslas0 =V@
`ou +ust include spaces around t0e trueFfalse operators suc0 as
>MM>
C O N F I D E N T I A L '2/
October 2!
C Shell % The exit Statement
"
.o stop e6ecuting a script, use t0e exit state+ent.
"
Synta6
if = [ans2er MM >Duit?@ t0en
e6it
endif
#ote: you can c0ecC t0e e6it status using [status =i.e. ec0o
[status@
C O N F I D E N T I A L '2(
October 2!
C Shell % Tr"e8False O,erators
"
#u+bers only
L , LM , N , and NM
"
#u+bers and strings
MM , ^M
"
Strings
Mb , ^b
Set 6 M >0i t0ere?
$f = >[6? Mb 0iR @ t0en K.
'. .0e 2ildcard c0aracters used 0ere are not regular e6pressions, t0ey
are t0e file na+e 2idcards used in co++ands suc0 as ls
2. DonSt use Duotation +arCs around t0e 0iR 0ere
C O N F I D E N T I A L '28
October 2!
C Shell % Tr"e8False O,erators
"
Co+binations
33 logical A#D
]] logical O4
$f = [var MM 2( 33 [var2 L 2( @ t0en K
"
,ile attributes
`ou can test a fileSs attributes: r =read@, 2 =2rite@, 6
=e6ecutable@, e =e6istence@, o =o2ners0ip@, I =Iero
lengt0@, f =plain file@, or d =directory@
$f = *r Ft+pF+yfile 33 *o Ft+pF+yfile @ t0en K.
C O N F I D E N T I A L '2-
October 2!
C Shell % 6ariables ( Constants
"
`ou can get a trueFfalse value by testing a variable:
[Xvar .rue if variable 0as a value
,alse if variable 0as not yet been
assigned a value
[var .rue if variable is not Iero, variable
+ust be a nu+ber
,alse if variable is Iero or null
7rror +essage if variable is not a
nu+ber
C O N F I D E N T I A L '29
October 2!
C Shell % 6ariables ( Constants
"
76a+ples:
set var M >a?
= [Xvar @ true
= [var @ synta6 error
= a @ synta6 error
= >a? @ synta6 error
set var M 9
= [Xvar @ true
= [var @ true
= 9 @ true
= >9? @ true
C O N F I D E N T I A L '2)
October 2!
C Shell % 6ariables ( Constants
"
76a+ples:
set var M
= [Xvar @ true
= [var @ false
= @ false
= >? @ false
set var M >?
= [Xvar @ true
= [var @ false
= >? @ false
= @ false
C O N F I D E N T I A L '!
October 2!
E$ercise &2 % Tr"e8False
O,erators
Using t0e follo2ing values for variables:
set var' M
set var2 M -
set var! M >t0is is te6t?
Are t0e follo2ing true or falseX
'. =[Xvar2@
Ans2er: .rue
2. =[var2@
Ans2er: .rue
C O N F I D E N T I A L '!'
October 2!
E$ercise &2 % Tr"e8False
O,erators
!. =[Xvar'@
Ans2er: .rue
/. =[var'@
Ans2er: ,alse
(. =[Xvar!@
Ans2er: .rue
8. =9(@
Ans2er: .rue
-. =@
Ans2er: ,alse
C O N F I D E N T I A L '!2
October 2!
E$ercise &2 % Tr"e8False
O,erators
9. =>[var!? Mb tR@
Ans2er: .rue
). =>[var!? Mb >tR?@
Ans2er: ,alse
'. =[var' N ( 33 [var2 N (@
Ans2er: ,alse
''. =[var' N ( ]] [var2 N (@
Ans2er: .rue
'2. = >[var!? MM >t0is is te6t?@
Ans2er: .rue
C O N F I D E N T I A L '!!
October 2!
C Shell % Command Line In,"t
"
`ou can use variables ['*[) to access para+eters
typed after t0e script na+e
"
[ 0olds t0e co++and na+e, [' 0olds t0e value of t0e
first argu+ent, and so on.
A scriptna+e var' var2 var! var/
[ M scriptna+e
[' M var'
[2 M var2
[! M var!
[/ M var/
C O N F I D E N T I A L '!/
October 2!
C Shell % Command Line In,"t
"
76a+ple:
A cat +yscript
Z^ FbinFcs0
ec0o >your co++and 2as: [?
ec0o >your first para+eter 2as : ['?
ec0o >all your para+eters 2ere: [R?
A +yscript 0orray for captain spaulding
your co++and 2as: +yscript
your first para+eter 2as: 0orray
all your para+eters 2ere: 0orray for captain spaulding
C O N F I D E N T I A L '!(
October 2!
C Shell % Command Line In,"t
"
More variables associated 2it0 t0e co++and line:
[Zargv nu+ber of co++and line argu+ents
[R abbreviation for all para+eters
[argv sa+e as [
[argv;'< sa+e as ['
K
[argv;)< sa+e as [)
[argv;'< note: not t0e sa+e as ['
[argv;''<
K
#ote: allo2s you to use a variable in t0e ; < i.e. [argv;[nu+<
C O N F I D E N T I A L '!8
October 2!
C Shell 0 Arithmetic
Use t0e _ sy+bol to perfor+ integer arit0+etic.
"
Calculations
B * R F general arit0+etic
A+odulus, calculates re+ainder after division
"
76a+ples
A set var2 M -
A _ var' M [var2 B 8W ec0o [var'
'!
A _ var' M [var2 A 2W ec0o [var'
'
A _ var' M !/( R -W ec0o [var'
2/'(
C O N F I D E N T I A L '!-
October 2!
C Shell 0 Arithmetic
"
S0ort0and notations
BB plus plus, add ' to a variable
** +inus +inus, subtracts ' fro+ a variable
FM divides value
BM adds value
*M subtracts value
RM +ultiplies value
"
76a+ples
A _ var'BB
A _ var'* *
A _ var' BM (  _ var' M [var' B(
A_ var' RM '  _ var' M [var' R '
C O N F I D E N T I A L '!9
October 2!
C Shell 0 Arithmetic
"
Use awk or bc to perfor+ floating point operations
A set var' M /(
A set var2 M !.8()
A ec0o >[var' [var2? ] a2C QTprint [' R [2US
'8/.8((
A ec0o >[var' R [var2? ] bc
'8/.8((
A ec0o >scale M 2W [var'F[var2? ] bc
'2.2)
C O N F I D E N T I A L '!)
October 2!
E$ercise &! % Command Line
Arg"ments
&rite a script t0at taCes 2 nu+ber as argu+ents.
'. Do a test to see if t0e correct nu+ber of argu+ents 0ave
been entered on t0e co++and line. `ouSll be using t0e
[Zargv variable, 20ic0 0olds t0e nu+ber of co++and line
argu+ents.
2. .0e script 2ill output t0e follo2ing infor+ation:
"
&0et0er eac0 nu+ber is even or odd
"
.0e average of t0e 2 nu+bers
76a+ple:
A e6ercise'!.cs0 /9 !
/9 is even
! is odd
.0e average of t0e 2 nu+bers is 2(.(
C O N F I D E N T I A L '/
October 2!
E$ercise &! % Command Line
Arg"ments
Z^ FbinFcs0
if =[Zargv ^M 2@ t0en
ec0o >Usage: [ N'L N2L?
e6it
endif
_var' M [' A 2
if =[var' MM @ t0en
ec0o >[' is even?
else
ec0o >[' is odd?
endif
_var2 M [2 A 2
if =[var2 MM @ t0en
ec0o >[2 is even?
else
ec0o >[2 is odd?
endif
set avg M dec0o >scaleM2W=['B[2@F2? ] bcd
ec0o >.0e average of t0e 2 nu+bers is [avg?
C O N F I D E N T I A L '/'
October 2!
C Shell % The while Loo,
"
$f you 2ould liCe a set of co++ands to e6ecute
repeatedly, you can use a while loop.
"
Synta6
set nu+ber M '
20ile = [nu+ber N '8 @
ec0o [nu+ber
_ nu+berBB
end
C O N F I D E N T I A L '/2
October 2!
C Shell % The while Loo,
"
76a+ple
set badinput M >true?
20ile = >[badinput? MM >true? @
ec0o >7nter so+e input: >
set input M [N
if = >[input? MM >?@ t0en Z user did not enter a value
set badinput M >true?
ec0o >Bad input, try again?
ec0o >Eit return to continue?
set PunC M [N Z pause t0e screen
clear Z clear t0e screen
else Z if user entered a value
set badinput M >false?
endif
end
C O N F I D E N T I A L '/!
October 2!
C Shell % The foreach Loo,
"
$f you 2ould liCe a set of co++ands to e6ecute
repeatedly, you can also use a foreach loop. .0is is
useful 20en processing +ultiple files 2it0 t0e sa+e
co++ands.
"
Synta6
foreac0 NvariableL = dls R.repd @
Nco++andL [NvariableL
end
"
76a+ple:
foreac0 file = dls R.repd @
sed –n Q[pS [file
end
C O N F I D E N T I A L '//
October 2!
C Shell % The switch Statement
"
So+eti+es youSll need to test a value for
+any different values. `ou can eit0er 2rite
+any if state+ents, or you can use switch
state+ent instead.
C O N F I D E N T I A L '/(
October 2!
C Shell % The switch Statement
"
Synta6
s2itc0 =[userna+e@
case ;7e<;%6<;$i<;.t<:
e6it
breaCs2
case ;A*M<R:
+ail [userna+e N FproPectF+ailFfirst0alf
_ usertotalBB
breaCs2
case ;#*Y<R:
+ail [userna+e N FproPectF+ailF2aitlist
_ 2aittotalBB
breaCs2
default:
+ail root N FproPectF+ailFproble+
e6it
ends2
C O N F I D E N T I A L '/8
October 2!
C Shell % #lobal 6ariables
"
Created 2it0 t0e setenv co++and
"
aisible to your current s0ell and all your c0ild
processes
"
Use printenv or env to see all global
variables
"
Jlobal variables are auto+atically passed to
your scripts, local variables are not
C O N F I D E N T I A L '/-
October 2!
C Shell % The PATE 6ariable
"
.0e 1A.E variable contains a list of directories to be
searc0ed for co++ands typed at t0e pro+pt or
included in your scripts. .o ensure t0at your
co++ands 2ill be found 20en your script is run, you
can define t0e 1A.E at t0e top of your script.
"
Set using t0e global variable 1A.E
setenv 1A.E FusrFbin:Fbin:FusrFucb:.
setenv 1A.E [T1A.EU:FusrFlocalFbin
"
Set using t0e local variable path
set pat0 M =FusrFbin Fbin FusrFucb .@
set pat0 M =[pat0 FusrFlocalFbin@
C O N F I D E N T I A L '/9
October 2!
C Shell % The break ( continue
Statements
.0e break and continue state+ents are used inside
looping structures suc0 as a while loop. =.0ey also
2orC in a foreach loop@
"
continue +oves you bacC to t0e beginning of
t0e 20ile loop
"
break +oves you out past t0e 20ile loop
C O N F I D E N T I A L '/)
October 2!
"
76a+ple:
20ile = [var! MM ( @
ec0o >enter a value?
set ans2er M [N
if =[Xans2er@ t0en
continue
else
if =[ans2er MM >Duit?@ t0en
breaC
endif
K
end
C Shell % The break ( continue
Statements
C O N F I D E N T I A L '(
October 2!
C Shell % E$it Stat"s
U#$% co++ands 0ave an e6it status
"
Access t0roug0 $status
"
#ote: +ost U#$% co++ands 2ill return a
Iero if successful. .0is translates into a
false if you 2ant to use it in an if state+ent.
C O N F I D E N T I A L '('
October 2!
Ac4noBledgements
"
1resentation adapted fro+ UC 76tension
class entitled >Advanced U#$% Utilities and
S0ell 1rogra++ing?, instructor Susan Barr
C O N F I D E N T I A L '(2
October 2!
A,,endi$ A
"
.0e >petc0ip? file:
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
#ote:,ile ,or+at 
petOna+e:species:breed:DOB:vetOe6penseOli+it:o2nerOfna+e:o2nerOlna+e:id
C O N F I D E N T I A L '(!
October 2!
A,,endi$ 5
"
.0e >grepfile? file:
.0is line contains a nu+ber: '2!/
.0is line ends in an %
.0is line ends in a dollar sign [
\ .0is line begins 2it0 a carat
.0is line ends in a carat \
Ei, +y na+e is Bob
Ei, +y na+e is Bib
Ei, +y na+e is Babs
.0is is a date in t0e eig0ties :9F'!F9/:
.0is is a date in t0e nineties :-F(F)2:
Eere is an :A:
Eere are ! :AAA:s
Eere are ( :AAAAA:s
C O N F I D E N T I A L '(/
October 2!
A,,endi$ C
"
.0e >c0ecCing? file:
'':'F!F'))/:A+er. 76press:2/!.
'2:2F'F'))/:CitibanC aisa:'/.)9
'!:2F'2F'))/:1ac. Jas37lec.:!).-
'/:2F'2F'))/:1acific Bell:8(.((
D2:2F'/F'))/:ABC $nc.:'/.
D':'F!F'))/:$4S:(/.
#ote: ,ile for+at  c0ecC nu+ber:date:na+e of party:a+ount
C O N F I D E N T I A L '((
October 2!

Related Interests

\!
sed QFalp0a[F,Fo+ega[FsFabc[F[abcFgS filena+e
\! \! \!
sed QsFab;c[<Fab6[FgS filena+e

sed QF[[FdS filena+e
\!
C O N F I D E N T I A L 8
October 2!
sed- insert ( add Commands
"
insert and add are +ulti*line co++ands. .0ey reDuire a
bacCslas0 =V@ at t0e end of eac0 line in order to continue t0e
co++and.
"
$nsert =insert before t0e line specified@
A cat sedfile'
'iV
.0is is a ne2 line
A sed –f sedfile' petc0ip
This is a neB line
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
K
C O N F I D E N T I A L 8'
October 2!
sed- insert and add Commands
"
Add =add after t0e line specified@
A cat sedfile2
Z .0is is a co++ent
'aV
.0is is a ne2 lineV
And so is t0is
A sed –f sedfile2 petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
This is a neB line
And so is this
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
K
C O N F I D E N T I A L 82
October 2!
sed- insert and add Commands
"
$nsert before eac0 line starting 2it0 M
A cat sedfile!
F\MFiV
.0is is a ne2 line
A sed –f sedfile! petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
This is a neB line
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
This is a neB line
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
K
C O N F I D E N T I A L 8!
October 2!
sed- Command Files
"
.0e first line of te6t in t0e data file is processed t0roug0
all t0e sed co++ands you list in your sed instruction
file. .0en, t0e ne6t line is processed, and so on
C O N F I D E N T I A L 8/
October 2!
sed- Command Files
A cat sedfile/
'iV
.0is file is petc0ip
FMaggyFcV
Maggy is lost^
FCorCyFsFcatFdogF
A sed –f sedfile/ petc0ip
This 1ile is ,etchi,
CorCy =Big Boy@:dog:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
)agg/ is lostC
1retel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
K
C O N F I D E N T I A L 8(
October 2!
sed- Command Files
A cat sedfile(
F\MFiV
.0is is before t0e M line
F\MFd
A sed –f sedfile( petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
This is be1ore the ) line
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
This is be1ore the ) line
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
C O N F I D E N T I A L 88
October 2!
sed- Command Files
A cat sedfile(
F\MFd
F\MFiV
.0is is before t0e M line
A sed –f sedfile( petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
#ote: order of co++ands +atters^
C O N F I D E N T I A L 8-
October 2!
sed- Carriage Returns
"
At ti+es you 2ill 2ant to insert a carriage return into
your sed replace-with section or searc0 for a carriage
return in t0e search-for section of a sed co++and.
"
$nsert a carriage return in t0e replace section of a
sed co++and. $n t0e replace-with section of t0e
co++and, use a bacCslas0 c0aracter =V@, t0en type
in t0e carriage return. Continue your co++and on
t0e ne6t line.
C O N F I D E N T I A L 89
October 2!
sed- Carriage Returns
A cat file'
sysad+in: sysad+
training: Pane,arc0ie,peggy,PacC
acct: nelson,+iller,+oore,rand
A cat sedfile(
sF:.RF:V
Fg
sF,FV
Fg
C O N F I D E N T I A L 8)
October 2!
sed- Carriage Returns
A sed –f sedfile( file'
sysad+in:
sysad+
training:
Pane
arc0ie
peggy
PacC
acct:
nelson
+iller
+oore
rand
C O N F I D E N T I A L -
October 2!
E$ercise = % )"lti0Line sed
Commands
'. &rite a sed file to c0ange petc0ip as follo2s
a. Add a ne2 line to t0e botto+ of t0e file
Eotdoggie:dog:C0o2:2F2F')98:/:Ho0n:Si+s:/-/2'
b. C0ange Maggy fro+ a 5ab Mi6 to a Springer
Spaniel
Ans2er:
[aV
Eotdoggie:dog:C0o2:2F2F')98:/:Ho0n:Si+s:/-/2'
F\MaggyFsF5ab Mi6FSpringer SpanielF
C O N F I D E N T I A L -'
October 2!
E$ercise = % )"lti0Line sed
Commands
2. &rite a sed file to c0ange petc0ip as follo2s
a. Add >CA? to t0e end of all lines
b. 5ooC for DSE, c0ange to >Do+estic S0ort Eair?
c. Delete all ferrets
Ans2er:
sF[F:CAF
sF:DSE:F:Do+estic S0ort Eair:F
F:ferret:Fd
C O N F I D E N T I A L -2
October 2!
UNIX Utilities 0 awk
"
awk processes structured files. $t assu+es you 0ave
colu+ns and ro2s. .0ere is a version of awk called
nawk 20ic0 includes t0e ability to create functions 2it0in
your co++ands. nawk 2ill not be covered 0ere, but you
are encouraged to follo2*up on your o2n. awk uses
egrep*liCe regular e6pressions.
"
Synta6:
awk –f progra+*file filena+e
or
awk Qprogra+S filena+e
C O N F I D E N T I A L -!
October 2!
awk % 5asic Commands
A a2C –,: QTprint [',[2,[!,[/US petc0ip
CorCy =Big Boy@ cat DSE !F'9F')))
SpunCy dog Jer+an S0eppard 8F'(F2
Maggy dog 5ab Mi6 )F2!F2'
1retIel dog .errier Mi6 )F!F'))8
Milly cat DSE 'F2F22
Otis cat DSE 'F2F22
,red ferret '2F/F2'
5ucCy cat D5E (F2'F'))(
S0elby dog Jolden 4etriever -F!F22
#ote: .0e [', [2, etc. represent t0e fields in eac0 line. .0e co++a prints a
space. .0e –, option defines t0e field separator c0aracter =space by default@.
C O N F I D E N T I A L -/
October 2!
awk % 5asic Commands
A cat a2C'
Tprint [',[2,[!,[/U
Tprint [(,[8,[-U
Tprint >?U
A a2C –,: *f a2C' petc0ip
CorCy =Big Boy@ cat DSE !F'9F')))
( ,red S+it0
SpunCy dog Jer+an S0eppard 8F'(F2
- Gi+ 4eed
Maggy dog 5ab Mi6 )F2!F2'
'2 .o+ Hones
K
C O N F I D E N T I A L -(
October 2!
awk % C"rl/ 5races
"
`ou +ay include +ultiple co++ands inside t0e curly
braces. 1ut a carriage return after eac0 co++and, or else
separate t0e co++ands 2it0 se+icolons.
Tprint [',[2,[!,[/
print [(,[8,[-
print >?U
Tprint [',[2,[!,[/W print [(,[8,[-W print >?U
T
print [',[2,[!,[/
print [(,[8,[-
print >?
U
C O N F I D E N T I A L -8
October 2!
awk % Printing +et"rns ( Tabs
"
Use Vn to print a carriage return, and Vt to print a tab.
A cat a2C2
Tprint [',[2,[!,[/ >Vn? [(,[8,[- >Vn?U
A a2C –,: *f a2C2 petc0ip
CorCy =Big Boy@ cat DSE !F'9F')))
( ,red S+it0
SpunCy dog Jer+an S0eppard 8F'(F2
- Gi+ 4eed
Maggy dog 5ab Mi6 )F2!F2'
'2 .o+ Hones
K
C O N F I D E N T I A L --
October 2!
awk % Processing a S"bset o1
+oBs Using Strings
"
A subset of t0e ro2s of t0e files are processed by using a
string searc0 before t0e curly braces.
"
String aalues
Fregular*e6pressionF
field b Fregular*e6pressionF
^ Fregular*e6pressionF
field ^b Fregular e6pressionF
"
Boolean aalues
]] logical O4
33 logical A#D
C O N F I D E N T I A L -9
October 2!
awk % Processing a S"bset o1
+oBs Using Strings
"
76a+ples:
A a2C –,: QF5enaF Tprint [8,[-,[(US petc0ip
5ena Eatc0er (
A a2C –,: Q['bFMillyF Tprint [',[2,[!,[/US petc0ip
Milly cat DSE 'F2F22
A a2C –,: Q['bF\MF 33 ['bFy[F Tprint [',[(US petc0ip
Maggy '2
Milly !
C O N F I D E N T I A L -)
October 2!
awk % Processing a S"bset o1
+oBs Using N"meric 6al"es
"
A subset of t0e ro2s of t0e files are processed by using a
nu+eric searc0 before t0e curly braces.
"
#u+eric aalues
field MM value
field ^M value
field L value
field LM value
field N value
field NM value
C O N F I D E N T I A L 9
October 2!
awk % Processing a S"bset o1
+oBs Using N"meric 6al"es
"
76a+ples:
A a2C –,: Q[( N / Tprint [8,[-,[(US petc0ip
Betty S+it0 !
Ben Stiller !
Brian Gennedy '
A a2C –,: Q[( MM '2 Tprint [8,[-,[(US petc0ip
.o+ Hones '2
Diane 5ee '2
A a2C –,: Q[( L ( 33 [( N ' Tprint [',[(US petc0ip
SpunCy -
C O N F I D E N T I A L 9'
October 2!
awk % Processing a S"bset o1
+oBs Bith )"lti,le Searches
A cat a2C!
[2bFcatF Tprint >VtBuy so+e cat food for > ['U
[2bFdogF Tprint >VtBuy so+e dog food for > ['U
[2bFferretF Tprint >VtBuy so+e ferret food for > ['U
A a2C –,: *f a2C! petc0ip
Buy so+e cat food for CorCy =Big Boy@
Buy so+e dog food for SpunCy
Buy so+e dog food for Maggy
Buy so+e dog food for 1retIel
Buy so+e cat food for Milly
K
C O N F I D E N T I A L 92
October 2!
E$ercise @ % awk Commands
4efer to t0e file in Appendi6 C, 2rite an awk co++and to:
'. 1rint a list of parties contained in t0e file c0ecCing
Ans2er: a2C –,: QTprint [!US c0ecCing
2. 1rint a list of parties and ite+ nu+bers for ite+s 2ritten
in ,ebruary
Ans2er: a2C –,: Q[2bFVFF Tprint [!,['US c0ecCing
!. 1rint t0e nu+bers for c0ecCs 2ritten for +ore t0at ['
Ans2er: a2C –,: Q['^bF\;Dd<F 33 [/ L ' Tprint ['US c0ecCing
/. 1rint t0e dates and parties for all deposits
Ans2er: a2C –,: Q['bF\DF Tprint [2,[!US c0ecCing
C O N F I D E N T I A L 9!
October 2!
awk % 5E#IN ( END Sections
"
`ou +ay add a B7J$# or 7#D section to your awk script
in order to process infor+ation before or after any ro2s
are processed.
A cat a2C/
B7J$# Tprint >1artyVtVtC0ecC A+ount?U
['bF\;*)<F Tprint [! >Vt? [/U
A a2C –,: *f a2C/ c0ecCing
1arty C0ecC A+ount
A+er. 76press 2/!.
CitibanC aisa '/.)9
1ac. Jas37lec. !).-
1acific Bell 8(.((
C O N F I D E N T I A L 9/
October 2!
awk % 6ariables
"
Any 2ord t0at is not a Cey 2ord 2ill be considered a
variable na+e by awk. awk does contain so+e
variables t0at it Ceeps tracC of auto+atically.
"
awk aariables
,$57#AM7 na+e of t0e data file
,S field separator, defaults to spaces
#, nu+ber of fields in current record
#4 nu+ber of t0e current record =i.e. line Z@
O,S output field separator, represented
by a co++a in print state+ents, defaults
to a space
C O N F I D E N T I A L 9(
October 2!
awk % 6ariables
"
76a+ples:
A a2C –,: Q#4 LM ! 33 #4 NM ( Tprint [8,[-US petc0ip
.o+ Hones
5ena Eatc0er
Betty S+it0
A a2C –,: Q7#D Tprint >.0ere are >#4? records in >,$57#AM7US petc0ip
.0ere are ) records in petc0ip
C O N F I D E N T I A L 98
October 2!
awk % 6ariables
"
76a+ples:
A cat lo2cost
B7J$# T,SM>:?WO,SM>K?U
[( N / Tprint [8,[-,[(U
A a2C –f lo2cost petc0ip
BettyKS+it0K!
BenKStillerK!
BrianKGennedyK'
C O N F I D E N T I A L 9-
October 2!
awk % User De1ined 6ariables
"
aariables can be user defined.
A cat a2C8
B7J$# T
,SM>:?
totalM
U
['bF\DF TtotalMtotalB[/U
['bF\;*)<F TtotalMtotal*[/U
7#D Tprint >Balance is: > totalU
A a2C –f a2C8 c0ecCing
Balance is: '/'(./
C O N F I D E N T I A L 99
October 2!
awk % Arithmetic
"
awk can be used to perfor+ arit0+etic operations.
"
Su++ary
B * R F standard arit0+etic
A re+ainder
BB add '
** subtract '
C O N F I D E N T I A L 9)
October 2!
awk % Standard Arithmetic
"
Addition
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint ['B[!US
!(('2.(/!
"
Division and Multiplication
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint ['F[!US
.!!92!
A ec0o S'2 ./(8- !((.(/! .!/-S ] a2C QTprint [2R[/US
.'(9/-(
C O N F I D E N T I A L )
October 2!
awk % +emainder Arithmetic
"
4e+ainder
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [2A2US
'.(
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint ['A2US

A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [/A2US

A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [!A2US
.(/!
C O N F I D E N T I A L )'
October 2!
awk % Add8S"btract & Arithmetic
"
Add one or subtract one
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint BB[/US
!(
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint [/BBUS
!/
A ec0o S'2 /(8-.( !((.(/! !/S ] a2C QTprint **[/US
!!
C O N F I D E N T I A L )2
October 2!
E$ercise ; % )ore awk
4eferring to t0e petc0ip file, 2rite an awk co++and to:
'. Jive a total of all t0e +a6i+u+ a+ounts o2ners are
2illing to pay for e+ergency services
Ans2er:
B7J$# T
,SM>:?
totalM
U
TtotalMtotalB[(U
7#D Tprint >.otal for e+ergency service: > totalU
2. &rite a co++and to +ultiply t0e nu+ber (8.)- by
(/.!.
Ans2er: ec0o S(8.)- (/.!S ] a2C QTprint ['R[2US
C O N F I D E N T I A L )!
October 2!
E$ercise ; % )ore awk
!. 1rint a c0art of pet na+es, species, and id nu+bers.
1ut 0eaders on t0e output data. 1rint a total
nu+ber of pets at t0e botto+ of t0e c0art.
Ans2er:
B7J$# Tprint >#a+eVtVtSpeciesVt$D?U
Tprint ['?Vt??Vt?[2?Vt?[9U
7#D Tprint >.otal nu+ber of pets: >#4U
/. 5ist lines (*'
Ans2er: a2C –,: Q#4 LM ( 33 #4 NM ' Tprint [US petc0ip
(. 5ist ani+als 20ose o2ners are 2illing to pay LM
[',. on +edical costs.
Ans2er: a2C –,: Q[( LM ' Tprint ['US petc0ip
C O N F I D E N T I A L )/
October 2!
awk % F"nctions
"
awk co+es 2it0 so+e built*in functions. Eere are a
select fe2:
"
split taCes a string and inserts itSs fields into an array
split=string, array, field*separator@
"
substr e6tracts a set of c0aracters out of a string
substr=string, start*position, +a6*lengt0@
"
lengt0 returns t0e nu+ber of c0aracters in a string
lengt0=string@
C O N F I D E N T I A L )(
October 2!
awk % F"nctions
"
76a+ples:
Use substr to s0orten t0e data output
T
petna+e M substr=[',',(@
print petna+e >Vt? [(
U
C O N F I D E N T I A L )8
October 2!
awk % F"nctions
"
76a+ples:
Use lengt0 to deter+ine t0e data output
$f =lengt0=['@ L (@
T
petna+e M substr=[',',(@
print petna+e >Vt? [(
U
else
Tprint [' >Vt? [(U
C O N F I D E N T I A L )-
October 2!
C Shell Programming
"
Uses of t0e C s0ell
"
4unning C s0ell scripts
"
5ocal variables
"
Obtaining user input
"
cuoting
"
Using s0ell variables in awk and sed
"
C s0ell redirection – input, output, 3 error +essages
"
.0e if state+ent
"
Co++and line input
"
C s0ell arit0+etic
"
.0e while loop
"
.0e foreach loop
"
.0e switch state+ent
"
Jlobal variables
"
.0e break and continue state+ents
"
76it status
C O N F I D E N T I A L )9
October 2!
C Shell E$ercises
"
76ercise ) – &riting a Si+ple C S0ell Script
"
76ercise ' – cuoting
"
76ercise '' – 4edirection
"
76ercise '2 – .rueF,alse Operators
"
76ercise '! – Co++and 5ine Argu+ents
C O N F I D E N T I A L ))
October 2!
C Shell % Uses o1 the C Shell
"
.0e C s0ell can be used as a co++and interpreter
or a progra++ing language. $n t0is training, t0e
focus is on t0e progra++ing aspects of t0e C s0ell.
"
A co++and interpreter
A ls
file'file2 file!
"
A progra++ing language
A cat firstscript
Z^ FbinFcs0
Z .0is is a co++ent
7c0o >.0is is +y first C s0ell script?
A firstscript
.0is is +y first C s0ell script
C O N F I D E N T I A L '
October 2!
C Shell % +"nning C Shell
Scri,ts
.0ere are ! 2ays to run a C s0ell script:
'. Use t0e source co++and. .0is runs t0e script
co++ands in t0e current s0ell.
A source +yscript
2. .ype in t0e script na+e at t0e pro+pt. .0is starts up
a sub*s0ell in 20ic0 to run t0e +yscript co++ands.
A +yscript
!. 1recede t0e script na+e 2it0 FbinFcs0. .0is starts
up a sub*s0ell in 20ic0 to run +yscript co++ands.
A FbinFcs0 +yscript
#ote: you +ust 0ave read 3 e6ecute per+issions to use tec0niDue 2,
read per+ission to use tec0niDue ' or !
C O N F I D E N T I A L ''
October 2!
C Shell % Local 6ariables
"
5ocal variables:
"
Created 2it0 t0e set co++and
"
aisible only to your current s0ell
"
Use set co++and to see all local variables
"
76a+ples:
A set abc M >'2!?
ec0o [abc
'2!
C O N F I D E N T I A L '2
October 2!
C Shell % Local 6ariables
"
76a+ples:
A set
c2d F2orCingFtraining
0istory 2
0o+e Fe6portF0o+eF
noclobber
pat0 =FusrFbin usrFlocalFbin Fe6portF0o+eFbin .@
pro+pt A
s0ell FbinFcs0
abc '2!
C O N F I D E N T I A L '!
October 2!
C Shell % Local 6ariables
"
$f t0ere is any roo+ for confusion, use curly braces
around your variable na+e.
"
76a+ple:
A ec0o [TabcU/(8
'2!/(8
C O N F I D E N T I A L '/
October 2!
C Shell % Obtaining User In,"t
"
Obtaining user input interactively, 20ile t0e script is
running.
A cat +yscript
Z^ FbinFcs0
ec0o –n >$nput a value: >
set na+e M [N
ec0o [na+e
A +yscript
$nput a value: &2!?<
'2!/(
C O N F I D E N T I A L '(
October 2!
E$ercise > % 3riting a Sim,le C
Shell Scri,t
&rite a script t0at prints options for t0e user on t0e
screen per follo2ing instructions:
'. $nclude Z^ FbinFcs0 on your first line
2. $nclude co++ents at t0e top of your script after
t0e first line. $nclude your na+e, t0e script
na+e, a description of 20at t0e script does, and
t0e last date you updated t0e script. .0is is a
good 0abit to develop.
C O N F I D E N T I A L '8
October 2!
E$ercise > % 3riting a Sim,le C
Shell Scri,t
!. Eave your script ec0o t0e follo2ing to t0e user:
C0ecCing
'. Add a c0ecC or deposit
2. 4e+ove a c0ecC or deposit
!. Calculate Balance
C0oose an Option:
/. 4ead t0e userSs response into a variable.
C O N F I D E N T I A L '-
October 2!
E$ercise > % 3riting a Sim,le C
Shell Scri,t
Ans2er:
Z^ FbinFcs0
Z Brian M. Appold
Z c0ecCing.cs0
Z .0is script +anages a c0ecCing account
Z 5ast updated: Oct '! 2!
ec0o >C0ecCing?
ec0o >?
ec0o >'. Add a c0ecC or deposit?
ec0o >2. 4e+ove a c0ecC or deposit?
ec0o >!. Calculate Balance?
ec0o >?
ec0o –n >C0oose and Option: >
set c0oice M [N
C O N F I D E N T I A L '9
October 2!
C Shell 0 D"oting
"
cuoting
Q Duotes everyt0ing e6cept ^
> Duotes everyt0ing e6cept ^, d, and [
d run co++and first, insert output into
surrounding co++and
V Duotes ne6t ' c0aracter =including ^@
C O N F I D E N T I A L ')
October 2!
C Shell 0 D"oting
"
76a+ples:
"
Set*up variable
A set var' M >abc?
"
Double Duotes donSt Duote [, single Duotes do
A ec0o Q[var'S  [var'
A ec0o >[var'?  abc
"
.0e bacC Duote c0aracter is different t0an single
Duote c0aracter
A ec0o ddated  Sun #ov '2 22:!:!- 1S. '))(
C O N F I D E N T I A L ''
October 2!
C Shell 0 D"oting
"
#eit0er single or double Duotes 2orC on t0e ^
C0aracter. Only t0e bacCslas0 2ill 2orC.
A ec0o 0ello^t0ere
t0ere: 7vent not found
A ec0o >0ello^t0ere?
Un+atc0ed >.
A ec0o Q0ello^t0ereS
Un+atc0ed Q.
A ec0o 0elloV^t0ere
0ello^t0ere
C O N F I D E N T I A L '''
October 2!
C Shell 0 D"oting
"
Single and double Duotes bot0 protect t0e
bacCslas0 c0aracter = V @.
A ec0o Vvar'  var'
A ec0o QV[var'S  V[var'
A ec0o >V[var'?  Vabc
C O N F I D E N T I A L ''2
October 2!
C Shell % Using Shell 6ariables
in sed and awk
"
$n +ost cases, you can use a s0ell variable by ending your
single Duoted string rig0t before t0e variable, t0en start it up
again rig0t after.
"
76a+ple:
A set lineno M 2
A a2C Q#4MM',#4MMQ[linenoS Tprint [US petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
A sed –n Q',S[linenoSpS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
C O N F I D E N T I A L ''!
October 2!
C Shell % Using Shell 6ariables
in sed and awk
"
Eo2ever, if your variable is a string containing spaces,
you +ust include double Duotes around t0e variable.
"
76a+ple:
A set na+e M QBig BoyS
A a2C –,: QFS?[na+e?SF Tprint [US petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
A sed –n QFS?[na+e?SFpS petc0ip
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
C O N F I D E N T I A L ''/
October 2!
C Shell % Using Shell 6ariables
in sed and awk
"
,or awk: $f your variable is a string containing spaces
and you are inside a print state+ent, t0en synta6 is +ore
co+ple6. $nclude one double Duote rig0t before your first
single Duoted string ends, and one rig0t after your
second single Duoted string begins.
"
76a+ple:
A set +ypet M >`our ani+alSs na+e is >
A a2C –,: QTprint >S?[+ypet?S? ['US petc0ip
`our ani+alSs na+e is CorCy =Big Boy@
`our ani+alSs na+e is SpunCy
K
#ote: t0is breaCs into ! pieces QTprint >S >[+ypet? Q? ['US
C O N F I D E N T I A L ''(
October 2!
E$ercise & % D"oting
'. &rite a sed co++and to list lines containing t0e
string stored in t0e variable [petna+e.
Ans2er: sed –n QFS?[petna+e?SFpS petc0ip
2. &rite an awk co++and to list t0e na+es of pets
20ose +a6i+u+ e+ergency costs can e6ceed t0e
value stored in [+a6a+ount.
Ans2er: a2C –,: Q[( LS?[+a6a+ount?S Tprint ['US petc0ip
C O N F I D E N T I A L ''8
October 2!
C Shell 0 +edirection
"
4edirecting output
L redirect output
L3 redirect output and errors
LL append
LL3 append output and errors
] pipe
"
.o prevent accidentally over*2riting files 2it0
redirection, set noclobber. .o over*ride noclobber,
use an e6cla+ation point =^@
L^ or L3^
C O N F I D E N T I A L ''-
October 2!
C Shell 0 +edirection
"
$f noclobber is set, t0e append sy+bol 2ill only append
to t0e end of an e6isting file. `ou need to use an
e6cla+ation point if you 2ant it to create t0e file.
LL^
LL3^
"
Multiple co++and redirection
A ls W date W 20o L outfile
A =ls W date W 20o@ L outfile
A =ls bananas L outfile@ L3 errfile
"
4edirection input
N
C O N F I D E N T I A L ''9
October 2!
C Shell 0 +edirection
"
#ote: &0en t0e s0ell sees t0e redirection sy+bol =L
or L3@, t0e s0ell Ieros out t0e file being 2ritten to if it
e6ists, or creates an e+pty file if it does not. `ouSll
notice t0is 20en:
'. `our interrupt a progra+ 2it0 \C before any output is
generated – t0e e+pty file gets created
2. `ou >sort abc L abc? .0e file abc is Ieroed out before
being sorted. `ou inadvertently erase your file.
C O N F I D E N T I A L '')
October 2!
E$ercise && % +edirection
Ans2er t0e follo2ing Duestions for eac0 of t0e
e6a+ples belo2. &0at files are created by t0e
co++and, and 20at infor+ation is stored in eac0 fileX
'. A =ls L outfile8@ L3 outfile -
Ans2er: outfile8 created, contains ls output
outfile- created, contains errors
2. A ==ls W date W 20o@ L outfile9@ L3 outfile)
Ans2er: outfile9 created, contains output of ls, date,
and 20o co++ands
outfile) created, contains errors
C O N F I D E N T I A L '2
October 2!
E$ercise && % +edirection
!. &0at is t0e difference bet2een t0e follo2ing 2
co++andsX
A ls L +ore
A ls ] +ore
Ans2er: '
st
– 2rites to file +ore
2
nd
– pipe ls output to +ore
/. &0at 2ill 0appen if you run t0is co++andX
A sort +yfile L^ +yfile
Ans2er: get an e+pty file, +yfile gets erased
C O N F I D E N T I A L '2'
October 2!
E$ercise && % +edirection
(. &0y +ig0t you set up a co++and t0is 2ayX
A =find F *na+e abc –print L abc.out@ L3 FdevFnull
Ans2er: errors go to a >blacC 0ole?
8. &0at does t0is co++and doX
A =find F *na+e abc –print L QttyS@ L3 FdevFnull
Ans2er: output goes to tty =ter+inal nu+ber@
errors go to >blacC 0ole?
C O N F I D E N T I A L '22
October 2!
C Shell % The if Statement
"
Use an if state+ent to perfor+ an operation if a
value is >true?. ,or t0e C s0ell if state+ent, true
+eans ' =i.e. non*Iero@ and false +eans .
"
Synta6
if = [var MM '(@ t0en
ec0o >eureCa?
endif
C O N F I D E N T I A L '2!
October 2!
C Shell % The if Statement
if ='@ t0en
ec0o >t0is is true?
else
ec0o >t0is is false?
endif
#ote:
then +ust be on t0e sa+e line as if, or else use a bacCslas0 =V@
`ou +ust include spaces around t0e trueFfalse operators suc0 as
>MM>
C O N F I D E N T I A L '2/
October 2!
C Shell % The exit Statement
"
.o stop e6ecuting a script, use t0e exit state+ent.
"
Synta6
if = [ans2er MM >Duit?@ t0en
e6it
endif
#ote: you can c0ecC t0e e6it status using [status =i.e. ec0o
[status@
C O N F I D E N T I A L '2(
October 2!
C Shell % Tr"e8False O,erators
"
#u+bers only
L , LM , N , and NM
"
#u+bers and strings
MM , ^M
"
Strings
Mb , ^b
Set 6 M >0i t0ere?
$f = >[6? Mb 0iR @ t0en K.
'. .0e 2ildcard c0aracters used 0ere are not regular e6pressions, t0ey
are t0e file na+e 2idcards used in co++ands suc0 as ls
2. DonSt use Duotation +arCs around t0e 0iR 0ere
C O N F I D E N T I A L '28
October 2!
C Shell % Tr"e8False O,erators
"
Co+binations
33 logical A#D
]] logical O4
$f = [var MM 2( 33 [var2 L 2( @ t0en K
"
,ile attributes
`ou can test a fileSs attributes: r =read@, 2 =2rite@, 6
=e6ecutable@, e =e6istence@, o =o2ners0ip@, I =Iero
lengt0@, f =plain file@, or d =directory@
$f = *r Ft+pF+yfile 33 *o Ft+pF+yfile @ t0en K.
C O N F I D E N T I A L '2-
October 2!
C Shell % 6ariables ( Constants
"
`ou can get a trueFfalse value by testing a variable:
[Xvar .rue if variable 0as a value
,alse if variable 0as not yet been
assigned a value
[var .rue if variable is not Iero, variable
+ust be a nu+ber
,alse if variable is Iero or null
7rror +essage if variable is not a
nu+ber
C O N F I D E N T I A L '29
October 2!
C Shell % 6ariables ( Constants
"
76a+ples:
set var M >a?
= [Xvar @ true
= [var @ synta6 error
= a @ synta6 error
= >a? @ synta6 error
set var M 9
= [Xvar @ true
= [var @ true
= 9 @ true
= >9? @ true
C O N F I D E N T I A L '2)
October 2!
C Shell % 6ariables ( Constants
"
76a+ples:
set var M
= [Xvar @ true
= [var @ false
= @ false
= >? @ false
set var M >?
= [Xvar @ true
= [var @ false
= >? @ false
= @ false
C O N F I D E N T I A L '!
October 2!
E$ercise &2 % Tr"e8False
O,erators
Using t0e follo2ing values for variables:
set var' M
set var2 M -
set var! M >t0is is te6t?
Are t0e follo2ing true or falseX
'. =[Xvar2@
Ans2er: .rue
2. =[var2@
Ans2er: .rue
C O N F I D E N T I A L '!'
October 2!
E$ercise &2 % Tr"e8False
O,erators
!. =[Xvar'@
Ans2er: .rue
/. =[var'@
Ans2er: ,alse
(. =[Xvar!@
Ans2er: .rue
8. =9(@
Ans2er: .rue
-. =@
Ans2er: ,alse
C O N F I D E N T I A L '!2
October 2!
E$ercise &2 % Tr"e8False
O,erators
9. =>[var!? Mb tR@
Ans2er: .rue
). =>[var!? Mb >tR?@
Ans2er: ,alse
'. =[var' N ( 33 [var2 N (@
Ans2er: ,alse
''. =[var' N ( ]] [var2 N (@
Ans2er: .rue
'2. = >[var!? MM >t0is is te6t?@
Ans2er: .rue
C O N F I D E N T I A L '!!
October 2!
C Shell % Command Line In,"t
"
`ou can use variables ['*[) to access para+eters
typed after t0e script na+e
"
[ 0olds t0e co++and na+e, [' 0olds t0e value of t0e
first argu+ent, and so on.
A scriptna+e var' var2 var! var/
[ M scriptna+e
[' M var'
[2 M var2
[! M var!
[/ M var/
C O N F I D E N T I A L '!/
October 2!
C Shell % Command Line In,"t
"
76a+ple:
A cat +yscript
Z^ FbinFcs0
ec0o >your co++and 2as: [?
ec0o >your first para+eter 2as : ['?
ec0o >all your para+eters 2ere: [R?
A +yscript 0orray for captain spaulding
your co++and 2as: +yscript
your first para+eter 2as: 0orray
all your para+eters 2ere: 0orray for captain spaulding
C O N F I D E N T I A L '!(
October 2!
C Shell % Command Line In,"t
"
More variables associated 2it0 t0e co++and line:
[Zargv nu+ber of co++and line argu+ents
[R abbreviation for all para+eters
[argv sa+e as [
[argv;'< sa+e as ['
K
[argv;)< sa+e as [)
[argv;'< note: not t0e sa+e as ['
[argv;''<
K
#ote: allo2s you to use a variable in t0e ; < i.e. [argv;[nu+<
C O N F I D E N T I A L '!8
October 2!
C Shell 0 Arithmetic
Use t0e _ sy+bol to perfor+ integer arit0+etic.
"
Calculations
B * R F general arit0+etic
A+odulus, calculates re+ainder after division
"
76a+ples
A set var2 M -
A _ var' M [var2 B 8W ec0o [var'
'!
A _ var' M [var2 A 2W ec0o [var'
'
A _ var' M !/( R -W ec0o [var'
2/'(
C O N F I D E N T I A L '!-
October 2!
C Shell 0 Arithmetic
"
S0ort0and notations
BB plus plus, add ' to a variable
** +inus +inus, subtracts ' fro+ a variable
FM divides value
BM adds value
*M subtracts value
RM +ultiplies value
"
76a+ples
A _ var'BB
A _ var'* *
A _ var' BM (  _ var' M [var' B(
A_ var' RM '  _ var' M [var' R '
C O N F I D E N T I A L '!9
October 2!
C Shell 0 Arithmetic
"
Use awk or bc to perfor+ floating point operations
A set var' M /(
A set var2 M !.8()
A ec0o >[var' [var2? ] a2C QTprint [' R [2US
'8/.8((
A ec0o >[var' R [var2? ] bc
'8/.8((
A ec0o >scale M 2W [var'F[var2? ] bc
'2.2)
C O N F I D E N T I A L '!)
October 2!
E$ercise &! % Command Line
Arg"ments
&rite a script t0at taCes 2 nu+ber as argu+ents.
'. Do a test to see if t0e correct nu+ber of argu+ents 0ave
been entered on t0e co++and line. `ouSll be using t0e
[Zargv variable, 20ic0 0olds t0e nu+ber of co++and line
argu+ents.
2. .0e script 2ill output t0e follo2ing infor+ation:
"
&0et0er eac0 nu+ber is even or odd
"
.0e average of t0e 2 nu+bers
76a+ple:
A e6ercise'!.cs0 /9 !
/9 is even
! is odd
.0e average of t0e 2 nu+bers is 2(.(
C O N F I D E N T I A L '/
October 2!
E$ercise &! % Command Line
Arg"ments
Z^ FbinFcs0
if =[Zargv ^M 2@ t0en
ec0o >Usage: [ N'L N2L?
e6it
endif
_var' M [' A 2
if =[var' MM @ t0en
ec0o >[' is even?
else
ec0o >[' is odd?
endif
_var2 M [2 A 2
if =[var2 MM @ t0en
ec0o >[2 is even?
else
ec0o >[2 is odd?
endif
set avg M dec0o >scaleM2W=['B[2@F2? ] bcd
ec0o >.0e average of t0e 2 nu+bers is [avg?
C O N F I D E N T I A L '/'
October 2!
C Shell % The while Loo,
"
$f you 2ould liCe a set of co++ands to e6ecute
repeatedly, you can use a while loop.
"
Synta6
set nu+ber M '
20ile = [nu+ber N '8 @
ec0o [nu+ber
_ nu+berBB
end
C O N F I D E N T I A L '/2
October 2!
C Shell % The while Loo,
"
76a+ple
set badinput M >true?
20ile = >[badinput? MM >true? @
ec0o >7nter so+e input: >
set input M [N
if = >[input? MM >?@ t0en Z user did not enter a value
set badinput M >true?
ec0o >Bad input, try again?
ec0o >Eit return to continue?
set PunC M [N Z pause t0e screen
clear Z clear t0e screen
else Z if user entered a value
set badinput M >false?
endif
end
C O N F I D E N T I A L '/!
October 2!
C Shell % The foreach Loo,
"
$f you 2ould liCe a set of co++ands to e6ecute
repeatedly, you can also use a foreach loop. .0is is
useful 20en processing +ultiple files 2it0 t0e sa+e
co++ands.
"
Synta6
foreac0 NvariableL = dls R.repd @
Nco++andL [NvariableL
end
"
76a+ple:
foreac0 file = dls R.repd @
sed –n Q[pS [file
end
C O N F I D E N T I A L '//
October 2!
C Shell % The switch Statement
"
So+eti+es youSll need to test a value for
+any different values. `ou can eit0er 2rite
+any if state+ents, or you can use switch
state+ent instead.
C O N F I D E N T I A L '/(
October 2!
C Shell % The switch Statement
"
Synta6
s2itc0 =[userna+e@
case ;7e<;%6<;$i<;.t<:
e6it
breaCs2
case ;A*M<R:
+ail [userna+e N FproPectF+ailFfirst0alf
_ usertotalBB
breaCs2
case ;#*Y<R:
+ail [userna+e N FproPectF+ailF2aitlist
_ 2aittotalBB
breaCs2
default:
+ail root N FproPectF+ailFproble+
e6it
ends2
C O N F I D E N T I A L '/8
October 2!
C Shell % #lobal 6ariables
"
Created 2it0 t0e setenv co++and
"
aisible to your current s0ell and all your c0ild
processes
"
Use printenv or env to see all global
variables
"
Jlobal variables are auto+atically passed to
your scripts, local variables are not
C O N F I D E N T I A L '/-
October 2!
C Shell % The PATE 6ariable
"
.0e 1A.E variable contains a list of directories to be
searc0ed for co++ands typed at t0e pro+pt or
included in your scripts. .o ensure t0at your
co++ands 2ill be found 20en your script is run, you
can define t0e 1A.E at t0e top of your script.
"
Set using t0e global variable 1A.E
setenv 1A.E FusrFbin:Fbin:FusrFucb:.
setenv 1A.E [T1A.EU:FusrFlocalFbin
"
Set using t0e local variable path
set pat0 M =FusrFbin Fbin FusrFucb .@
set pat0 M =[pat0 FusrFlocalFbin@
C O N F I D E N T I A L '/9
October 2!
C Shell % The break ( continue
Statements
.0e break and continue state+ents are used inside
looping structures suc0 as a while loop. =.0ey also
2orC in a foreach loop@
"
continue +oves you bacC to t0e beginning of
t0e 20ile loop
"
break +oves you out past t0e 20ile loop
C O N F I D E N T I A L '/)
October 2!
"
76a+ple:
20ile = [var! MM ( @
ec0o >enter a value?
set ans2er M [N
if =[Xans2er@ t0en
continue
else
if =[ans2er MM >Duit?@ t0en
breaC
endif
K
end
C Shell % The break ( continue
Statements
C O N F I D E N T I A L '(
October 2!
C Shell % E$it Stat"s
U#$% co++ands 0ave an e6it status
"
Access t0roug0 $status
"
#ote: +ost U#$% co++ands 2ill return a
Iero if successful. .0is translates into a
false if you 2ant to use it in an if state+ent.
C O N F I D E N T I A L '('
October 2!
Ac4noBledgements
"
1resentation adapted fro+ UC 76tension
class entitled >Advanced U#$% Utilities and
S0ell 1rogra++ing?, instructor Susan Barr
C O N F I D E N T I A L '(2
October 2!
A,,endi$ A
"
.0e >petc0ip? file:
CorCy =Big Boy@:cat:DSE:!F'9F'))):(:,red:S+it0:)(!(
SpunCy:dog:Jer+an S0eppard:8F'(F2:-:Gi+:4eed:)/(!8
Maggy:dog:5ab Mi6:)F2!F2':'2:.o+:Hones:)(''-
1retIel:dog:.errier Mi6:)F!F'))8:(:5ena:Eatc0er:)/98
Milly:cat:DSE:'F2F22:!:Betty:S+it0:)/(!)
Otis:cat:DSE:'F2F22:!:Ben:Stiller:/9-!/
,red:ferret::'2F/F2':':Brian:Gennedy:/-'(/
5ucCy:cat:D5E:(F2'F'))(:(:,ranC:Andre2s:)/9(2
S0elby:dog:Jolden 4etriever:-F!F22:'2:Diane:5ee:9(82!
#ote:,ile ,or+at 
petOna+e:species:breed:DOB:vetOe6penseOli+it:o2nerOfna+e:o2nerOlna+e:id
C O N F I D E N T I A L '(!
October 2!
A,,endi$ 5
"
.0e >grepfile? file:
.0is line contains a nu+ber: '2!/
.0is line ends in an %
.0is line ends in a dollar sign [
\ .0is line begins 2it0 a carat
.0is line ends in a carat \
Ei, +y na+e is Bob
Ei, +y na+e is Bib
Ei, +y na+e is Babs
.0is is a date in t0e eig0ties :9F'!F9/:
.0is is a date in t0e nineties :-F(F)2:
Eere is an :A:
Eere are ! :AAA:s
Eere are ( :AAAAA:s
C O N F I D E N T I A L '(/
October 2!
A,,endi$ C
"
.0e >c0ecCing? file:
'':'F!F'))/:A+er. 76press:2/!.
'2:2F'F'))/:CitibanC aisa:'/.)9
'!:2F'2F'))/:1ac. Jas37lec.:!).-
'/:2F'2F'))/:1acific Bell:8(.((
D2:2F'/F'))/:ABC $nc.:'/.
D':'F!F'))/:$4S:(/.
#ote: ,ile for+at  c0ecC nu+ber:date:na+e of party:a+ount
C O N F I D E N T I A L '((
October 2!

","static_promo_banner_cta_url":"https://www.scribd.com/"},"eligible_for_exclusive_trial_roadblock":false,"eligible_for_seo_roadblock":false,"exclusive_free_trial_roadblock_props_path":"/doc-page/exclusive-free-trial-props/236612319","flashes":[],"footer_props":{"urls":{"about":"/about","press":"/press","blog":"http://literally.scribd.com/","careers":"/careers","contact":"/contact","plans_landing":"/subscribe","referrals":"/referrals?source=footer","giftcards":"/giftcards","faq":"/faq","accessibility":"/accessibility-policy","faq_paths":{"accounts":"https://support.scribd.com/hc/sections/202246346","announcements":"https://support.scribd.com/hc/sections/202246066","copyright":"https://support.scribd.com/hc/sections/202246086","downloading":"https://support.scribd.com/hc/articles/210135046","publishing":"https://support.scribd.com/hc/sections/202246366","reading":"https://support.scribd.com/hc/sections/202246406","selling":"https://support.scribd.com/hc/sections/202246326","store":"https://support.scribd.com/hc/sections/202246306","status":"https://support.scribd.com/hc/en-us/articles/360001202872","terms":"https://support.scribd.com/hc/sections/202246126","writing":"https://support.scribd.com/hc/sections/202246366","adchoices":"https://support.scribd.com/hc/articles/210129366","paid_features":"https://support.scribd.com/hc/sections/202246306","failed_uploads":"https://support.scribd.com/hc/en-us/articles/210134586-Troubleshooting-uploads-and-conversions","copyright_infringement":"https://support.scribd.com/hc/en-us/articles/210128946-DMCA-copyright-infringement-takedown-notification-policy","end_user_license":"https://support.scribd.com/hc/en-us/articles/210129486","terms_of_use":"https://support.scribd.com/hc/en-us/articles/210129326-General-Terms-of-Use"},"publishers":"/publishers","static_terms":"/terms","static_privacy":"/privacy","copyright":"/copyright","ios_app":"https://itunes.apple.com/us/app/scribd-worlds-largest-online/id542557212?mt=8&uo=4&at=11lGEE","android_app":"https://play.google.com/store/apps/details?id=com.scribd.app.reader0&hl=en","books":"/books","sitemap":"/directory"}},"global_nav_props":{"header_props":{"logo_src":"/images/landing/home2_landing/scribd_logo_horiz_small.svg","root_url":"https://www.scribd.com/","search_term":"","small_logo_src":"/images/logos/scribd_s_logo.png","uploads_url":"/upload-document","search_props":{"redirect_to_app":true,"search_url":"/search","query":"","search_page":false}},"user_menu_props":null,"sidebar_props":{"urls":{"bestsellers":"https://www.scribd.com/bestsellers","home":"https://www.scribd.com/","saved":"/saved","subscribe":"/archive/pmp_checkout?doc=236612319&metadata=%7B%22context%22%3A%22pmp%22%2C%22action%22%3A%22start_trial%22%2C%22logged_in%22%3Afalse%2C%22platform%22%3A%22web%22%7D","top_charts":"/bestsellers","upload":"https://www.scribd.com/upload-document"},"categories":{"book":{"icon":"icon-ic_book","icon_filled":"icon-ic_book_fill","url":"https://www.scribd.com/books","name":"Books","type":"book"},"news":{"icon":"icon-ic_articles","icon_filled":"icon-ic_articles_fill","url":"https://www.scribd.com/news","name":"News","type":"news"},"audiobook":{"icon":"icon-ic_audiobook","icon_filled":"icon-ic_audiobook_fill","url":"https://www.scribd.com/audiobooks","name":"Audiobooks","type":"audiobook"},"magazine":{"icon":"icon-ic_magazine","icon_filled":"icon-ic_magazine_fill","url":"https://www.scribd.com/magazines","name":"Magazines","type":"magazine"},"document":{"icon":"icon-ic_document","icon_filled":"icon-ic_document_fill","url":"https://www.scribd.com/docs","name":"Documents","type":"document"},"sheet_music":{"icon":"icon-ic_songbook","icon_filled":"icon-ic_songbook_fill","url":"https://www.scribd.com/sheetmusic","name":"Sheet Music","type":"sheet_music"},"summary":{"icon":"icon-ic_globalnav_snapshot","icon_filled":"icon-ic_globalnav_snapshot_fill","url":"https://www.scribd.com/snapshots","name":"Snapshots","type":"summary"}},"nav_categories":["mixed","book","audiobook","magazine","document","sheet_music"],"selected_content_type":"mixed","username":"","search_overlay_props":{"search_input_props":{"focused":false,"keep_suggestions_on_blur":false}}}},"recommenders":{"related_titles_recommender":{"ids":[73002824,205792705,10963448,235945996,359575119,127788519,4028456,274004248,258188317,136020903,191086679,190447153,352587286,385289721,19323570,69709495,114658097,63324628,173909657,133744160,351063145,244157917,212863738,253264900,239488191,263504218,282766939,163646054,224419023,224258670,224369806,238704340,224355300,225916486,293461549,224410295,211302755,202691564,239588474,182553141,234028503,224326250,224426877,224349281,337536061,249309502,254039238,182565115,224306619,273440534,273582508,182546874,249308781,224285255,224252178,250006950,235583696,231689346,224248577,224270540,163580087,235411767,224248520,163564256,249308236,246897514,182560283,163579056,163647832,163603389,216442529,182522032,224266633,224420008],"title_link":null,"title":null,"track_opts":{"compilation_id":"jGWafrjjDGjq27ZSbX9i421pWDs=","module_id":"YgpCpa7QGBhl1gV0vPPLLMvFegw=","widget_name":"right sidebar","track_id":"flattened_recommender"}},"footer_recommenders":{"recommenders":[{"ids":[73002824,205792705,10963448,235945996,359575119,127788519,4028456,274004248,258188317,136020903,191086679,190447153,352587286,385289721,19323570,69709495,114658097,63324628,173909657,133744160,351063145],"title_link":null,"title":"Documents Similar To UNIX Utilities and Shell Programming Part1","track_opts":{"compilation_id":"jGWafrjjDGjq27ZSbX9i421pWDs=","module_id":"W2efckt9JONmOJjgMz1U8WFCP/Y=","widget_name":"document_carousel"}}]},"seo_new_docs_recommenders":{"recommenders":[]},"documents":{"4028456":{"type":"document","id":4028456,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/4028456/149x198/f9b9374bcb/1536940630?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/4028456/298x396/692067e34d/1536940630?v=1","title":"Credit Card Number 378282246310005\n","short_title":"Credit Card Number 378282246310005\n","author":"api-1906461","tracking":{"object_type":"document","object_id":4028456,"track":"flattened_recommender","doc_uuid":"iblbJB76J5NbYnoOhleIm+WtPhc="},"url":"https://www.scribd.com/doc/4028456/Credit-Card-Number-378282246310005","top_badge":null},"10963448":{"type":"document","id":10963448,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/10963448/149x198/3d2db62b8d/1332431906?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/10963448/298x396/0e11ed28fe/1332431906?v=1","title":"ksh Scripting","short_title":"ksh Scripting","author":"George","tracking":{"object_type":"document","object_id":10963448,"track":"flattened_recommender","doc_uuid":"6Xe+0b7fWY7kJfjrgRnwuWbT4W8="},"url":"https://www.scribd.com/document/10963448/ksh-Scripting","top_badge":null},"19323570":{"type":"document","id":19323570,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/19323570/149x198/e927b63d85/1534104116?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/19323570/298x396/fd42174ac7/1534104116?v=1","title":"Credit Card Visa Hack","short_title":"Credit Card Visa Hack","author":"daisukeniwa1990","tracking":{"object_type":"document","object_id":19323570,"track":"flattened_recommender","doc_uuid":"BJRl2iGMnWdZRFcUZHhcSDbW24s="},"url":"https://www.scribd.com/document/19323570/Credit-Card-Visa-Hack","top_badge":null},"63324628":{"type":"document","id":63324628,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/63324628/149x198/9e586fd7cf/1356227948?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/63324628/298x396/a632c5a06a/1356227948?v=1","title":"Unix Shell Programming","short_title":"Unix Shell Programming","author":"grsrik","tracking":{"object_type":"document","object_id":63324628,"track":"flattened_recommender","doc_uuid":"aBQeWgepPnmrnoikK/vdYqFRhqs="},"url":"https://www.scribd.com/document/63324628/Unix-Shell-Programming","top_badge":null},"69709495":{"type":"document","id":69709495,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/69709495/149x198/547743bd14/1484095069?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/69709495/298x396/dbef903d66/1484095069?v=1","title":"Hadoop Installation Guide","short_title":"Hadoop Installation Guide","author":"Sri Ram","tracking":{"object_type":"document","object_id":69709495,"track":"flattened_recommender","doc_uuid":"XH7bl0cHcl6XnbFMkReQ00KRz4c="},"url":"https://www.scribd.com/doc/69709495/Hadoop-Installation-Guide","top_badge":null},"73002824":{"type":"document","id":73002824,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/73002824/149x198/9624128a4b/1536940128?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/73002824/298x396/9fbbd1e7d0/1536940128?v=1","title":"Carding 101","short_title":"Carding 101","author":"Peter Pham","tracking":{"object_type":"document","object_id":73002824,"track":"flattened_recommender","doc_uuid":"mQqlHTRdFlVkmeB6CII/D5gztyE="},"url":"https://www.scribd.com/document/73002824/Carding-101","top_badge":null},"114658097":{"type":"document","id":114658097,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/114658097/149x198/60bf63feb3/1354049714?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/114658097/298x396/b379d72b72/1354049714?v=1","title":"201205622","short_title":"201205622","author":"Sandhya Agrawal","tracking":{"object_type":"document","object_id":114658097,"track":"flattened_recommender","doc_uuid":"P+N0AYOOxhBclkpx3NTQ6Y+E8TU="},"url":"https://www.scribd.com/document/114658097/201205622","top_badge":null},"127788519":{"type":"document","id":127788519,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/127788519/149x198/e0ae3f769a/1433296550?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/127788519/298x396/640ad7163f/1433296550?v=1","title":"dfta_ref","short_title":"dfta_ref","author":"Deepak Chanda","tracking":{"object_type":"document","object_id":127788519,"track":"flattened_recommender","doc_uuid":"LLk0IweHWScKRWhqixK5FOnd0d8="},"url":"https://www.scribd.com/document/127788519/dfta-ref","top_badge":null},"133744160":{"type":"document","id":133744160,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/133744160/149x198/40a7b7d948/1420841542?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/133744160/298x396/9c675da2da/1420841542?v=1","title":"Write a UNIX Shell Lab1","short_title":"Write a UNIX Shell Lab1","author":"Zacarias Göldy","tracking":{"object_type":"document","object_id":133744160,"track":"flattened_recommender","doc_uuid":"uwNX59fZ4Kjh9ozahbxOmgqqaIM="},"url":"https://www.scribd.com/document/133744160/Write-a-UNIX-Shell-Lab1","top_badge":null},"136020903":{"type":"document","id":136020903,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/136020903/149x198/3849fe7a1f/1378893193?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/136020903/298x396/05d2e93d6e/1378893193?v=1","title":"All Dealers Username Password 8 6","short_title":"All Dealers Username Password 8 6","author":"Rajeswar Rayapati","tracking":{"object_type":"document","object_id":136020903,"track":"flattened_recommender","doc_uuid":"HFXGIFOlEAxG9kNrxg6JUCkgQhc="},"url":"https://www.scribd.com/doc/136020903/All-Dealers-Username-Password-8-6","top_badge":null},"163564256":{"type":"book","id":163564256,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/163564256/149x198/4d140b8606/1540023305?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/163564256/298x396/3f016be665/1540023305?v=1","title":"Beautiful Ruins: A Novel","short_title":"Beautiful Ruins","author":"Jess Walter","tracking":{"object_type":"document","object_id":163564256,"track":"flattened_recommender","doc_uuid":"xGG87HNk5zNEzbOQr4Ni4Y7HLEU="},"url":"https://www.scribd.com/book/163564256/Beautiful-Ruins-A-Novel","top_badge":null},"163579056":{"type":"book","id":163579056,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/163579056/149x198/e3ae8b9345/1540029072?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/163579056/298x396/c599e1583f/1540029072?v=1","title":"The Art of Racing in the Rain: A Novel","short_title":"The Art of Racing in the Rain","author":"Garth Stein","tracking":{"object_type":"document","object_id":163579056,"track":"flattened_recommender","doc_uuid":"hQ0sdjaWg0efPNCv6qLH3M68030="},"url":"https://www.scribd.com/book/163579056/The-Art-of-Racing-in-the-Rain-A-Novel","top_badge":null},"163580087":{"type":"book","id":163580087,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/163580087/149x198/df75726300/1540030082?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/163580087/298x396/012861be61/1540030082?v=1","title":"Bel Canto","short_title":"Bel Canto","author":"Ann Patchett","tracking":{"object_type":"document","object_id":163580087,"track":"flattened_recommender","doc_uuid":"T7X3Sb+qAv4PA9wBV1B8iamH5YI="},"url":"https://www.scribd.com/book/163580087/Bel-Canto","top_badge":null},"163603389":{"type":"book","id":163603389,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/163603389/149x198/7c1ceeb759/1540034790?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/163603389/298x396/2c8c5e4da3/1540034790?v=1","title":"A Prayer for Owen Meany: A Novel","short_title":"A Prayer for Owen Meany","author":"John Irving","tracking":{"object_type":"document","object_id":163603389,"track":"flattened_recommender","doc_uuid":"i8B+e5/dZymxA4i6W1IJDaFOzD8="},"url":"https://www.scribd.com/book/163603389/A-Prayer-for-Owen-Meany-A-Novel","top_badge":null},"163646054":{"type":"book","id":163646054,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/163646054/149x198/73d89ab0b4/1540022817?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/163646054/298x396/92feb6c9c7/1540022817?v=1","title":"Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America","short_title":"Devil in the Grove","author":"Gilbert King","tracking":{"object_type":"document","object_id":163646054,"track":"flattened_recommender","doc_uuid":"bjx/yLHOUXqnWG6ClV+zg7lbMUw="},"url":"https://www.scribd.com/book/163646054/Devil-in-the-Grove-Thurgood-Marshall-the-Groveland-Boys-and-the-Dawn-of-a-New-America","top_badge":null},"163647832":{"type":"book","id":163647832,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/163647832/149x198/974fcd39b2/1540022140?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/163647832/298x396/58f221bfa6/1540022140?v=1","title":"The Cider House Rules","short_title":"The Cider House Rules","author":"John Irving","tracking":{"object_type":"document","object_id":163647832,"track":"flattened_recommender","doc_uuid":"pWuByjJj+NxNKspebQwsKwALOyA="},"url":"https://www.scribd.com/book/163647832/The-Cider-House-Rules","top_badge":null},"173909657":{"type":"document","id":173909657,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/173909657/149x198/fcece32d6d/1381087562?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/173909657/298x396/5dd025251f/1381087562?v=1","title":"Bash Reference Manual","short_title":"Bash Reference Manual","author":"MeLi Pm","tracking":{"object_type":"document","object_id":173909657,"track":"flattened_recommender","doc_uuid":"1k+VYRs0FteeidNHmdhw+Hg6mHQ="},"url":"https://www.scribd.com/document/173909657/Bash-Reference-Manual","top_badge":null},"182522032":{"type":"book","id":182522032,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/182522032/149x198/e1b9e42cb5/1540023014?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/182522032/298x396/ddcc62ae69/1540023014?v=1","title":"The Bonfire of the Vanities: A Novel","short_title":"The Bonfire of the Vanities","author":"Tom Wolfe","tracking":{"object_type":"document","object_id":182522032,"track":"flattened_recommender","doc_uuid":"WHLI78jQPjkGPoXFYsuFCqRKyNU="},"url":"https://www.scribd.com/book/182522032/The-Bonfire-of-the-Vanities-A-Novel","top_badge":null},"182546874":{"type":"book","id":182546874,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/182546874/149x198/f82b3526b2/1540029994?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/182546874/298x396/8079e74998/1540029994?v=1","title":"The Love Affairs of Nathaniel P.: A Novel","short_title":"The Love Affairs of Nathaniel P.","author":"Adelle Waldman","tracking":{"object_type":"document","object_id":182546874,"track":"flattened_recommender","doc_uuid":"/pFg4jPxqvmEMkWVfKqVmNd8lg8="},"url":"https://www.scribd.com/book/182546874/The-Love-Affairs-of-Nathaniel-P-A-Novel","top_badge":null},"182553141":{"type":"book","id":182553141,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/182553141/149x198/9d8b4953ee/1540029399?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/182553141/298x396/89521cc859/1540029399?v=1","title":"The World Is Flat 3.0: A Brief History of the Twenty-first Century","short_title":"The World Is Flat 3.0","author":"Thomas L. Friedman","tracking":{"object_type":"document","object_id":182553141,"track":"flattened_recommender","doc_uuid":"puAhciHTUBx9M1B3OZPpIJMvDCM="},"url":"https://www.scribd.com/book/182553141/The-World-Is-Flat-3-0-A-Brief-History-of-the-Twenty-first-Century","top_badge":null},"182560283":{"type":"book","id":182560283,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/182560283/149x198/0601b1931c/1540026915?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/182560283/298x396/f6a21d4103/1540026915?v=1","title":"Wolf Hall: A Novel","short_title":"Wolf Hall","author":"Hilary Mantel","tracking":{"object_type":"document","object_id":182560283,"track":"flattened_recommender","doc_uuid":"7tqepPioAFwtnxcLsA2t0eu56/M="},"url":"https://www.scribd.com/book/182560283/Wolf-Hall-A-Novel","top_badge":null},"182565115":{"type":"book","id":182565115,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/182565115/149x198/825ad48fb6/1540028380?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/182565115/298x396/e6af4ca8dd/1540028380?v=1","title":"The Silver Linings Playbook: A Novel","short_title":"The Silver Linings Playbook","author":"Matthew Quick","tracking":{"object_type":"document","object_id":182565115,"track":"flattened_recommender","doc_uuid":"y2yHcVTmjJ0Jsc7h5lhZMZf8Orc="},"url":"https://www.scribd.com/book/182565115/The-Silver-Linings-Playbook-A-Novel","top_badge":null},"190447153":{"type":"document","id":190447153,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/190447153/149x198/178da18cba/1386599386?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/190447153/298x396/a6110a3cdb/1386599386?v=1","title":"bash_day2","short_title":"bash_day2","author":"anidcohen9058","tracking":{"object_type":"document","object_id":190447153,"track":"flattened_recommender","doc_uuid":"i/+WHAntODAOScFbcdrgTzEI7Ag="},"url":"https://www.scribd.com/document/190447153/bash-day2","top_badge":null},"191086679":{"type":"document","id":191086679,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/191086679/149x198/76fa1f585a/1386844728?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/191086679/298x396/34b8bf1255/1386844728?v=1","title":"ProjectObject Login Validation","short_title":"ProjectObject Login Validation","author":"Ashish Mallik","tracking":{"object_type":"document","object_id":191086679,"track":"flattened_recommender","doc_uuid":"Kxg8B/kTcWTyBoPEKp8EHxD6+eI="},"url":"https://www.scribd.com/document/191086679/ProjectObject-Login-Validation","top_badge":null},"202691564":{"type":"book","id":202691564,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/202691564/149x198/de3999cc66/1540032330?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/202691564/298x396/0ba4b4666c/1540032330?v=1","title":"Smart People Should Build Things: How to Restore Our Culture of Achievement, Build a Path for Entrepreneurs, and Create New Jobs in America","short_title":"Smart People Should Build Things","author":"Andrew Yang","tracking":{"object_type":"document","object_id":202691564,"track":"flattened_recommender","doc_uuid":"9ZS4DISBI3N65IQc4bQgTfBBswU="},"url":"https://www.scribd.com/book/202691564/Smart-People-Should-Build-Things-How-to-Restore-Our-Culture-of-Achievement-Build-a-Path-for-Entrepreneurs-and-Create-New-Jobs-in-America","top_badge":null},"205792705":{"type":"document","id":205792705,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/205792705/149x198/6ec83f4413/1496191647?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/205792705/298x396/f0bf3d8b32/1496191647?v=1","title":"Title Id","short_title":"Title Id","author":"CristianOria97","tracking":{"object_type":"document","object_id":205792705,"track":"flattened_recommender","doc_uuid":"DKowUoEgRjWsP0qD74vdLuFdTn0="},"url":"https://www.scribd.com/doc/205792705/Title-Id","top_badge":null},"211302755":{"type":"book","id":211302755,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/211302755/149x198/e130bab094/1540032834?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/211302755/298x396/19f10ceb3f/1540032834?v=1","title":"The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers","short_title":"The Hard Thing About Hard Things","author":"Ben Horowitz","tracking":{"object_type":"document","object_id":211302755,"track":"flattened_recommender","doc_uuid":"PIrBNvp8QMJQ1JN2PfcuIhqQ/cs="},"url":"https://www.scribd.com/book/211302755/The-Hard-Thing-About-Hard-Things-Building-a-Business-When-There-Are-No-Easy-Answers","top_badge":null},"212863738":{"type":"book","id":212863738,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/212863738/149x198/486257e90d/1540030711?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/212863738/298x396/40684a0550/1540030711?v=1","title":"The Unwinding: An Inner History of the New America","short_title":"The Unwinding","author":"George Packer","tracking":{"object_type":"document","object_id":212863738,"track":"flattened_recommender","doc_uuid":"5Sna3vkzZxTOyzbToKNBlCAdelg="},"url":"https://www.scribd.com/book/212863738/The-Unwinding-An-Inner-History-of-the-New-America","top_badge":null},"216442529":{"type":"book","id":216442529,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/216442529/149x198/e28b506e87/1540023804?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/216442529/298x396/716aaad647/1540023804?v=1","title":"Lovers at the Chameleon Club, Paris 1932: A Novel","short_title":"Lovers at the Chameleon Club, Paris 1932","author":"Francine Prose","tracking":{"object_type":"document","object_id":216442529,"track":"flattened_recommender","doc_uuid":"Y3mwOM6H6+oC5DJ+g30ymSk7nuY="},"url":"https://www.scribd.com/book/216442529/Lovers-at-the-Chameleon-Club-Paris-1932-A-Novel","top_badge":null},"224248520":{"type":"book","id":224248520,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224248520/149x198/0427bca488/1540034025?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224248520/298x396/505053db71/1540034025?v=1","title":"The Kitchen House: A Novel","short_title":"The Kitchen House","author":"Kathleen Grissom","tracking":{"object_type":"document","object_id":224248520,"track":"flattened_recommender","doc_uuid":"7HmwbGnA58ezqDAIyWHBvnNMkHA="},"url":"https://www.scribd.com/book/224248520/The-Kitchen-House-A-Novel","top_badge":null},"224248577":{"type":"book","id":224248577,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224248577/149x198/97fab15653/1540019689?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224248577/298x396/35883a5fcb/1540019689?v=1","title":"The Rosie Project: A Novel","short_title":"The Rosie Project","author":"Graeme Simsion","tracking":{"object_type":"document","object_id":224248577,"track":"flattened_recommender","doc_uuid":"/X4VF4QpnkyKplN63l+B9wCjjOY="},"url":"https://www.scribd.com/book/224248577/The-Rosie-Project-A-Novel","top_badge":null},"224252178":{"type":"book","id":224252178,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224252178/149x198/77a859fdd8/1540025854?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224252178/298x396/dfbec9e04b/1540025854?v=1","title":"Brooklyn: A Novel","short_title":"Brooklyn","author":"Colm Tóibín","tracking":{"object_type":"document","object_id":224252178,"track":"flattened_recommender","doc_uuid":"JFdSRG78X80Qz/WkFnYeGTEAxE0="},"url":"https://www.scribd.com/book/224252178/Brooklyn-A-Novel","top_badge":null},"224258670":{"type":"book","id":224258670,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224258670/149x198/b2ee6fe90c/1540036976?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224258670/298x396/eb9e673a3c/1540036976?v=1","title":"The Prize: The Epic Quest for Oil, Money & Power","short_title":"The Prize","author":"Daniel Yergin","tracking":{"object_type":"document","object_id":224258670,"track":"flattened_recommender","doc_uuid":"P46OwPumVrUlxI5kfFkZzLo0CAk="},"url":"https://www.scribd.com/book/224258670/The-Prize-The-Epic-Quest-for-Oil-Money-Power","top_badge":null},"224266633":{"type":"book","id":224266633,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224266633/149x198/196f9b9902/1540037449?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224266633/298x396/c65dbae83f/1540037449?v=1","title":"The Perks of Being a Wallflower","short_title":"The Perks of Being a Wallflower","author":"Stephen Chbosky","tracking":{"object_type":"document","object_id":224266633,"track":"flattened_recommender","doc_uuid":"lmV4NtCqlVXzzembOfyI0ZVkMYw="},"url":"https://www.scribd.com/book/224266633/The-Perks-of-Being-a-Wallflower","top_badge":null},"224270540":{"type":"book","id":224270540,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224270540/149x198/246ef7879c/1540036239?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224270540/298x396/b9d115f691/1540036239?v=1","title":"The Master","short_title":"The Master","author":"Colm Tóibín","tracking":{"object_type":"document","object_id":224270540,"track":"flattened_recommender","doc_uuid":"B9YvRV+xRIcRcD6gZ545AZwKLqk="},"url":"https://www.scribd.com/book/224270540/The-Master","top_badge":null},"224285255":{"type":"book","id":224285255,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224285255/149x198/a61ed79e9b/1540019902?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224285255/298x396/a6488a57c8/1540019902?v=1","title":"The Flamethrowers: A Novel","short_title":"The Flamethrowers","author":"Rachel Kushner","tracking":{"object_type":"document","object_id":224285255,"track":"flattened_recommender","doc_uuid":"/1LnpY0G0OosKJWEQ3HKahkycYc="},"url":"https://www.scribd.com/book/224285255/The-Flamethrowers-A-Novel","top_badge":null},"224306619":{"type":"book","id":224306619,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224306619/149x198/5a300f585d/1540033520?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224306619/298x396/21c3e990fc/1540033520?v=1","title":"The Light Between Oceans: A Novel","short_title":"The Light Between Oceans","author":"M.L. Stedman","tracking":{"object_type":"document","object_id":224306619,"track":"flattened_recommender","doc_uuid":"0Z6n/nB2/i/Bsn9F1kvrsE9+Vkw="},"url":"https://www.scribd.com/book/224306619/The-Light-Between-Oceans-A-Novel","top_badge":null},"224326250":{"type":"book","id":224326250,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224326250/149x198/f1e7bf86b3/1540030275?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224326250/298x396/67d6eee06a/1540030275?v=1","title":"Steve Jobs","short_title":"Steve Jobs","author":"Walter Isaacson","tracking":{"object_type":"document","object_id":224326250,"track":"flattened_recommender","doc_uuid":"ZSToW37jjRs2LE251DXFLIMiuNE="},"url":"https://www.scribd.com/book/224326250/Steve-Jobs","top_badge":null},"224349281":{"type":"book","id":224349281,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224349281/149x198/c8e6142eca/1540038918?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224349281/298x396/121ea6d44a/1540038918?v=1","title":"How To Win Friends and Influence People","short_title":"How To Win Friends and Influence People","author":"Dale Carnegie","tracking":{"object_type":"document","object_id":224349281,"track":"flattened_recommender","doc_uuid":"H3dG5uktSUuQshUaxa+Xeqhno94="},"url":"https://www.scribd.com/book/224349281/How-To-Win-Friends-and-Influence-People","top_badge":null},"224355300":{"type":"book","id":224355300,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224355300/149x198/e0393734b6/1540026566?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224355300/298x396/fac4cdb725/1540026566?v=1","title":"Grand Pursuit: The Story of Economic Genius","short_title":"Grand Pursuit","author":"Sylvia Nasar","tracking":{"object_type":"document","object_id":224355300,"track":"flattened_recommender","doc_uuid":"jLuU+RO+PI6Upjx5U+x4kPsmqdk="},"url":"https://www.scribd.com/book/224355300/Grand-Pursuit-The-Story-of-Economic-Genius","top_badge":null},"224369806":{"type":"book","id":224369806,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224369806/149x198/d2fc5923b8/1540026821?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224369806/298x396/a026add765/1540026821?v=1","title":"The Emperor of All Maladies: A Biography of Cancer","short_title":"The Emperor of All Maladies","author":"Siddhartha Mukherjee","tracking":{"object_type":"document","object_id":224369806,"track":"flattened_recommender","doc_uuid":"TN/wK2sqc7IAMUIipBhYu4+fFUY="},"url":"https://www.scribd.com/book/224369806/The-Emperor-of-All-Maladies-A-Biography-of-Cancer","top_badge":null},"224410295":{"type":"book","id":224410295,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224410295/149x198/5f74dd59cd/1540026621?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224410295/298x396/58644b8626/1540026621?v=1","title":"Team of Rivals: The Political Genius of Abraham Lincoln","short_title":"Team of Rivals","author":"Doris Kearns Goodwin","tracking":{"object_type":"document","object_id":224410295,"track":"flattened_recommender","doc_uuid":"IqMsWcQ5sKhdKsEf+TyZSZGym8s="},"url":"https://www.scribd.com/book/224410295/Team-of-Rivals-The-Political-Genius-of-Abraham-Lincoln","top_badge":null},"224419023":{"type":"book","id":224419023,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224419023/149x198/7e946216e0/1540026539?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224419023/298x396/08758c4819/1540026539?v=1","title":"John Adams","short_title":"John Adams","author":"David McCullough","tracking":{"object_type":"document","object_id":224419023,"track":"flattened_recommender","doc_uuid":"mFaOAtSoH1GSQhKCJt6h5wwT52A="},"url":"https://www.scribd.com/book/224419023/John-Adams","top_badge":null},"224420008":{"type":"book","id":224420008,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224420008/149x198/7a7e91eff2/1540023438?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/224420008/298x396/7fdc43e330/1540023438?v=1","title":"The Constant Gardener: A Novel","short_title":"The Constant Gardener","author":"John le Carré","tracking":{"object_type":"document","object_id":224420008,"track":"flattened_recommender","doc_uuid":"ohvgnEAdbk8qLVvl2NGwROZmF3E="},"url":"https://www.scribd.com/book/224420008/The-Constant-Gardener-A-Novel","top_badge":null},"224426877":{"type":"book","id":224426877,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224426877/149x198/67b53f7428/1540023833?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/224426877/298x396/61c4862b68/1540023833?v=1","title":"Angela's Ashes: A Memoir","short_title":"Angela's Ashes","author":"Frank McCourt","tracking":{"object_type":"document","object_id":224426877,"track":"flattened_recommender","doc_uuid":"rAeHObGBtsaou7pGq4Y09g0zGGw="},"url":"https://www.scribd.com/book/224426877/Angela-s-Ashes-A-Memoir","top_badge":null},"225916486":{"type":"book","id":225916486,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/225916486/149x198/ceefd53ff2/1540029734?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/225916486/298x396/3fda0d41f4/1540029734?v=1","title":"A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story","short_title":"A Heartbreaking Work Of Staggering Genius","author":"Dave Eggers","tracking":{"object_type":"document","object_id":225916486,"track":"flattened_recommender","doc_uuid":"/OnwKtZ5NmexeuBlv/pj2yT+QE4="},"url":"https://www.scribd.com/book/225916486/A-Heartbreaking-Work-Of-Staggering-Genius-A-Memoir-Based-on-a-True-Story","top_badge":null},"231689346":{"type":"book","id":231689346,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/231689346/149x198/8820ffce2e/1540019878?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/231689346/298x396/8022aee462/1540019878?v=1","title":"The Blazing World: A Novel","short_title":"The Blazing World","author":"Siri Hustvedt","tracking":{"object_type":"document","object_id":231689346,"track":"flattened_recommender","doc_uuid":"dAtT9WfqsdP5ReFkdYIGmDfhKIs="},"url":"https://www.scribd.com/book/231689346/The-Blazing-World-A-Novel","top_badge":null},"234028503":{"type":"book","id":234028503,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/234028503/149x198/600d1fe3f9/1540032369?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/234028503/298x396/1455400f40/1540032369?v=1","title":"Bad Feminist: Essays","short_title":"Bad Feminist","author":"Roxane Gay","tracking":{"object_type":"document","object_id":234028503,"track":"flattened_recommender","doc_uuid":"aC99cbu9dQKbTiyyUbYXaTPcAz4="},"url":"https://www.scribd.com/book/234028503/Bad-Feminist-Essays","top_badge":null},"235411767":{"type":"book","id":235411767,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/235411767/149x198/ce356815f8/1540055094?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/235411767/298x396/a289a2fc2a/1540055094?v=1","title":"A Man Called Ove: A Novel","short_title":"A Man Called Ove","author":"Fredrik Backman","tracking":{"object_type":"document","object_id":235411767,"track":"flattened_recommender","doc_uuid":"Oh9/2hidDDJEa0f0QXryUTvYfv0="},"url":"https://www.scribd.com/book/235411767/A-Man-Called-Ove-A-Novel","top_badge":null},"235583696":{"type":"book","id":235583696,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/235583696/149x198/29700e772d/1540033118?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/235583696/298x396/46800f01c6/1540033118?v=1","title":"We Are Not Ourselves: A Novel","short_title":"We Are Not Ourselves","author":"Matthew Thomas","tracking":{"object_type":"document","object_id":235583696,"track":"flattened_recommender","doc_uuid":"OHnA/p7bobuwVR4jjuv/u+8iSck="},"url":"https://www.scribd.com/book/235583696/We-Are-Not-Ourselves-A-Novel","top_badge":null},"235945996":{"type":"document","id":235945996,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/235945996/149x198/a20c3bcae6/1407256159?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/235945996/298x396/1c7faad007/1407256159?v=1","title":"Unix Commands","short_title":"Unix Commands","author":"rajusawant","tracking":{"object_type":"document","object_id":235945996,"track":"flattened_recommender","doc_uuid":"Q1157LYvS8zCx8/6h/5CV82zCCY="},"url":"https://www.scribd.com/document/235945996/Unix-Commands","top_badge":null},"238704340":{"type":"book","id":238704340,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/238704340/149x198/58ed32b584/1540029094?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/238704340/298x396/d84f33deab/1540029094?v=1","title":"This Changes Everything: Capitalism vs. The Climate","short_title":"This Changes Everything","author":"Naomi Klein","tracking":{"object_type":"document","object_id":238704340,"track":"flattened_recommender","doc_uuid":"XPlVQf5cwQCCci4aPaLZreRKP2Q="},"url":"https://www.scribd.com/book/238704340/This-Changes-Everything-Capitalism-vs-The-Climate","top_badge":null},"239488191":{"type":"book","id":239488191,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/239488191/149x198/7381d3ba45/1540023655?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/239488191/298x396/891d3f4926/1540023655?v=1","title":"The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution","short_title":"The Innovators","author":"Walter Isaacson","tracking":{"object_type":"document","object_id":239488191,"track":"flattened_recommender","doc_uuid":"cOPUlmb+0qFtaBF+10UqOG+TLyE="},"url":"https://www.scribd.com/book/239488191/The-Innovators-How-a-Group-of-Hackers-Geniuses-and-Geeks-Created-the-Digital-Revolution","top_badge":null},"239588474":{"type":"book","id":239588474,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/239588474/149x198/8a4150948e/1540033369?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/239588474/298x396/644cc7285e/1540033369?v=1","title":"Rise of ISIS: A Threat We Can't Ignore","short_title":"Rise of ISIS","author":"Jay Sekulow","tracking":{"object_type":"document","object_id":239588474,"track":"flattened_recommender","doc_uuid":"I/O5cStVSxb5zEkp5gUiJGrhzzU="},"url":"https://www.scribd.com/book/239588474/Rise-of-ISIS-A-Threat-We-Can-t-Ignore","top_badge":null},"244157917":{"type":"book","id":244157917,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/244157917/149x198/ce51d31665/1540024130?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/244157917/298x396/d0cbd421a3/1540024130?v=1","title":"Yes Please","short_title":"Yes Please","author":"Amy Poehler","tracking":{"object_type":"document","object_id":244157917,"track":"flattened_recommender","doc_uuid":"tJ5WltQ/7k3mexsWCJ6bz6PVYgM="},"url":"https://www.scribd.com/book/244157917/Yes-Please","top_badge":null},"246897514":{"type":"book","id":246897514,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/246897514/149x198/9d722fcc90/1540034872?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/246897514/298x396/2244bff6fc/1540034872?v=1","title":"The Wallcreeper","short_title":"The Wallcreeper","author":"Nell Zink","tracking":{"object_type":"document","object_id":246897514,"track":"flattened_recommender","doc_uuid":"JrwIwOmeBlS9XJU1GhJulk6Hnac="},"url":"https://www.scribd.com/book/246897514/The-Wallcreeper","top_badge":null},"249308236":{"type":"book","id":249308236,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/249308236/149x198/345de5ca38/1540055237?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/249308236/298x396/4e9d2e54be/1540055237?v=1","title":"Interpreter of Maladies","short_title":"Interpreter of Maladies","author":"Jhumpa Lahiri","tracking":{"object_type":"document","object_id":249308236,"track":"flattened_recommender","doc_uuid":"PCFVxR/zz0ivB3v+sMGU9YxMxx8="},"url":"https://www.scribd.com/book/249308236/Interpreter-of-Maladies","top_badge":null},"249308781":{"type":"book","id":249308781,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/249308781/149x198/44cce4d99a/1540055357?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/249308781/298x396/3fb7c9a745/1540055357?v=1","title":"Life of Pi","short_title":"Life of Pi","author":"Yann Martel","tracking":{"object_type":"document","object_id":249308781,"track":"flattened_recommender","doc_uuid":"pTm8WpJlc2Qm1km4JkZwzsAhzOA="},"url":"https://www.scribd.com/book/249308781/Life-of-Pi","top_badge":null},"249309502":{"type":"book","id":249309502,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/249309502/149x198/a536db5ae1/1540055368?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/249309502/298x396/aa0185412b/1540055368?v=1","title":"Extremely Loud and Incredibly Close: A Novel","short_title":"Extremely Loud and Incredibly Close","author":"Jonathan Safran Foer","tracking":{"object_type":"document","object_id":249309502,"track":"flattened_recommender","doc_uuid":"ecRJkUDY7XI/Z1fRVS/yTvLKyR8="},"url":"https://www.scribd.com/book/249309502/Extremely-Loud-and-Incredibly-Close-A-Novel","top_badge":null},"250006950":{"type":"book","id":250006950,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/250006950/149x198/dfc24938b6/1540024393?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/250006950/298x396/a7ea4fedc0/1540024393?v=1","title":"The First Bad Man: A Novel","short_title":"The First Bad Man","author":"Miranda July","tracking":{"object_type":"document","object_id":250006950,"track":"flattened_recommender","doc_uuid":"4uRjSZ/V7lCG2/8gEdvmBOMrW/M="},"url":"https://www.scribd.com/book/250006950/The-First-Bad-Man-A-Novel","top_badge":null},"253264900":{"type":"book","id":253264900,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/253264900/149x198/5948645a35/1540033804?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/253264900/298x396/912824fccd/1540033804?v=1","title":"Sapiens: A Brief History of Humankind","short_title":"Sapiens","author":"Yuval Noah Harari","tracking":{"object_type":"document","object_id":253264900,"track":"flattened_recommender","doc_uuid":"cIMNPqmrRxMQu4Do1eUH1KyvhL4="},"url":"https://www.scribd.com/book/253264900/Sapiens-A-Brief-History-of-Humankind","top_badge":null},"254039238":{"type":"book","id":254039238,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/254039238/149x198/278d17c7f4/1540029904?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/254039238/298x396/8e93835fcc/1540029904?v=1","title":"Leaving Berlin: A Novel","short_title":"Leaving Berlin","author":"Joseph Kanon","tracking":{"object_type":"document","object_id":254039238,"track":"flattened_recommender","doc_uuid":"v8SKAkmwz/pTksBnbXqET6jr/lU="},"url":"https://www.scribd.com/book/254039238/Leaving-Berlin-A-Novel","top_badge":null},"258188317":{"type":"document","id":258188317,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/258188317/149x198/493cc3d3d2/1425937957?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/258188317/298x396/c0a110259e/1425937957?v=1","title":"UNIX Interview Questions","short_title":"UNIX Interview Questions","author":"utagore58","tracking":{"object_type":"document","object_id":258188317,"track":"flattened_recommender","doc_uuid":"C6gASkalpIOG4ze8so54+JubNY4="},"url":"https://www.scribd.com/document/258188317/UNIX-Interview-Questions","top_badge":null},"263504218":{"type":"book","id":263504218,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/263504218/149x198/5791495c90/1540031117?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/263504218/298x396/ca05b40921/1540031117?v=1","title":"Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future","short_title":"Elon Musk","author":"Ashlee Vance","tracking":{"object_type":"document","object_id":263504218,"track":"flattened_recommender","doc_uuid":"m1prgyNAM5Qh8y2PuKQihCXckZs="},"url":"https://www.scribd.com/book/263504218/Elon-Musk-Tesla-SpaceX-and-the-Quest-for-a-Fantastic-Future","top_badge":null},"273440534":{"type":"book","id":273440534,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/273440534/149x198/d972c41ea4/1540030975?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/273440534/298x396/79bdc35da6/1540030975?v=1","title":"The Incarnations: A Novel","short_title":"The Incarnations","author":"Susan Barker","tracking":{"object_type":"document","object_id":273440534,"track":"flattened_recommender","doc_uuid":"C6y2kzII2xoPq/Qg2+9Zq11Uxg4="},"url":"https://www.scribd.com/book/273440534/The-Incarnations-A-Novel","top_badge":null},"273582508":{"type":"book","id":273582508,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/273582508/149x198/1af6c958cc/1540027889?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/273582508/298x396/6f8ad65faa/1540027889?v=1","title":"You Too Can Have a Body Like Mine: A Novel","short_title":"You Too Can Have a Body Like Mine","author":"Alexandra Kleeman","tracking":{"object_type":"document","object_id":273582508,"track":"flattened_recommender","doc_uuid":"gB7btr3qFz1l1u1wXU1gmy4DkrU="},"url":"https://www.scribd.com/book/273582508/You-Too-Can-Have-a-Body-Like-Mine-A-Novel","top_badge":null},"274004248":{"type":"document","id":274004248,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/274004248/149x198/c631007691/1439149688?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/274004248/298x396/97601719c9/1439149688?v=1","title":"All Dealers Username Password only for sale","short_title":"All Dealers Username Password only for sale","author":"suresh","tracking":{"object_type":"document","object_id":274004248,"track":"flattened_recommender","doc_uuid":"Hs4+izD82Kqjv80+sfNT0+WvdH0="},"url":"https://www.scribd.com/doc/274004248/All-Dealers-Username-Password-only-for-sale","top_badge":null},"282766939":{"type":"book","id":282766939,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/282766939/149x198/0fd38dc477/1540030952?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/word_document/282766939/298x396/ce234488d0/1540030952?v=1","title":"Dispatches from Pluto: Lost and Found in the Mississippi Delta","short_title":"Dispatches from Pluto","author":"Richard Grant","tracking":{"object_type":"document","object_id":282766939,"track":"flattened_recommender","doc_uuid":"7wmeWBTo+NQ/m8zJMvDZYO5iuMY="},"url":"https://www.scribd.com/book/282766939/Dispatches-from-Pluto-Lost-and-Found-in-the-Mississippi-Delta","top_badge":null},"293461549":{"type":"book","id":293461549,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/293461549/149x198/133f5a7fcd/1540027430?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/293461549/298x396/077cb2a3ef/1540027430?v=1","title":"The New Confessions of an Economic Hit Man","short_title":"The New Confessions of an Economic Hit Man","author":"John Perkins","tracking":{"object_type":"document","object_id":293461549,"track":"flattened_recommender","doc_uuid":"8bwTWAkPfrH0YKkQA3J0muArW5s="},"url":"https://www.scribd.com/book/293461549/The-New-Confessions-of-an-Economic-Hit-Man","top_badge":null},"337536061":{"type":"book","id":337536061,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/337536061/149x198/e0fabe3d5f/1540034676?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/word_document/337536061/298x396/9e5f6dd316/1540034676?v=1","title":"The Sympathizer: A Novel (Pulitzer Prize for Fiction)","short_title":"The Sympathizer","author":"Viet Thanh Nguyen","tracking":{"object_type":"document","object_id":337536061,"track":"flattened_recommender","doc_uuid":"XhKlDfdXfgnwAVzNoun9vwxrI80="},"url":"https://www.scribd.com/book/337536061/The-Sympathizer-A-Novel-Pulitzer-Prize-for-Fiction","top_badge":null},"351063145":{"type":"document","id":351063145,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/351063145/149x198/44142054ef/1497290515?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/351063145/298x396/c4768014f5/1497290515?v=1","title":"Oracle Unix Commands","short_title":"Oracle Unix Commands","author":"subra1032","tracking":{"object_type":"document","object_id":351063145,"track":"flattened_recommender","doc_uuid":"hGUvbatmL0fBQZ7mB8mrSjS/ixA="},"url":"https://www.scribd.com/document/351063145/Oracle-Unix-Commands","top_badge":null},"352587286":{"type":"document","id":352587286,"thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/352587286/149x198/860248200e/1498810192?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/352587286/298x396/53c165bda1/1498810192?v=1","title":"Selection It To","short_title":"Selection It To","author":"Ryuzaky","tracking":{"object_type":"document","object_id":352587286,"track":"flattened_recommender","doc_uuid":"PuvNektPWUY5tTyh3smhAXfNAh8="},"url":"https://www.scribd.com/document/352587286/Selection-It-To","top_badge":null},"359575119":{"type":"document","id":359575119,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/359575119/149x198/a363d5b6fa/1506062164?v=1","retina_thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/359575119/298x396/f01c2d9d2e/1506062164?v=1","title":"Lab – Pipes, Redirection and REGEX","short_title":"Lab – Pipes, Redirection and REGEX","author":"Carlos Resultay","tracking":{"object_type":"document","object_id":359575119,"track":"flattened_recommender","doc_uuid":"gXAtGqMLiuxf7N8QT1u2s7fO1DI="},"url":"https://www.scribd.com/document/359575119/Lab-Pipes-Redirection-and-REGEX","top_badge":null},"385289721":{"type":"document","id":385289721,"thumb_url":"https://imgv2-2-f.scribdassets.com/img/document/385289721/149x198/18f90f4266/1533210943?v=1","retina_thumb_url":"https://imgv2-1-f.scribdassets.com/img/document/385289721/298x396/66a644bbed/1533210943?v=1","title":"LinuxCBT_EL-7_Edition_Notes.txt","short_title":"LinuxCBT_EL-7_Edition_Notes.txt","author":"Faisal Saeed Saeed","tracking":{"object_type":"document","object_id":385289721,"track":"flattened_recommender","doc_uuid":"F28QJoBdQIYfSdbCwhUftaW/5Y8="},"url":"https://www.scribd.com/document/385289721/LinuxCBT-EL-7-Edition-Notes-txt","top_badge":null}}},"seo_roadblock_props_path":"/doc-page/seo-roadblock-props/236612319","signup_context":null,"toolbar":{"search_path":"/search-4gen?allowed_pages=1%2C2%2C3%2C56%2C57%2C58%2C73%2C74%2C75%2C100%2C101%2C102%2C125%2C126%2C127&auth_token=siXAOzq6h9Dgiz1Bl3eKfGrdy%2B8%3D&authenticity_token=DdJsTzZJm%2B3a1fa4ermaadkSrYS9g%2BE0cBLhqEJtosyc1xq7jsPFYwX5IlyZud02rPbp3XEXT68tHKHcCiDEAA%3D%3D&expires=1540690439&wordDocumentId=236612319&wordUploadId=241046543"},"renewal_nag_props":null}-->