SlideShare a Scribd company logo
1 of 32
Handling Repetition
Presentation Subtitle
2
What is Handling Repetition ?
Handling Repetition is control structure also known as looping control structure,Handling Repetition is control structure also known as looping control structure,
is a type of control structure in programming languages that is used to simplify repetitive oris a type of control structure in programming languages that is used to simplify repetitive or
recursive tasks operation.recursive tasks operation.
Delete zero sized files in system.Delete zero sized files in system.
3
Code for write a script to delete zero sized files from a given directory
(and all its subdirectories) in Unix / Linux / Ubuntu
Code for write a script to delete zero sized files from a given directory
(and all its subdirectories) in Unix / Linux / Ubuntu
4
5
Script 19
Handling Repetition is control structure also known as looping control structure,Handling Repetition is control structure also known as looping control structure,
is a type of control structure in programming languages that is used to simplify repetitive oris a type of control structure in programming languages that is used to simplify repetitive or
recursive tasks operation.recursive tasks operation.
6
Repetitive tasks
1.1. The for loopThe for loop
2.2. The while loopThe while loop
3.3. The until loopThe until loop
7
The for loopThe for loop
The for loop is the first of the three shell looping constructs.
This loop allows for specification of a list of values.
A list of commands is executed for each value in the list.
8
for loop Syntaxfor loop Syntax
9
for loop Examplefor loop Example
$ cat for1.sh
i=1
for day in Mon Tue Wed Thu Fri
do
echo "Weekday $((i++)) : $day"
done
$ ./for1.sh
Weekday 1 : Mon
Weekday 2 : Tue
Weekday 3 : Wed
Weekday 4 : Thu
Weekday 5 : Fri
10
The while loopThe while loop
The while construct allows for repetitive execution of a list of commands, as long as the
command controlling the while loop executes successfully (exit status of zero)
The while construct allows for repetitive execution of a list of commands, as long as the
command controlling the while loop executes successfully (exit status of zero)
11
The while loopThe while loop
12
while loop Syntaxwhile loop Syntax
13
while loop Examplewhile loop Example
a=0
while [ $a -lt 10 ]
do
echo $a
a=`expr $a + 1`
done
14
The until loopThe until loop
15
until loop Syntaxuntil loop Syntax
until <TEST-COMMAND>;
do
CONSEQUENT - COMMANDS;
done
16
until loop Exampleuntil loop Example
until [ $DISKFUL -ge "90" ];
do
DATE=`date +%Y%m%d`
HOUR=`date +%H`
mkdir $WEBDIR/"$DATE"
while [ $HOUR -ne "00" ];
do
DESTDIR=$WEBDIR/"$DATE"/"$HOUR"
mkdir "$DESTDIR" mv $PICDIR/*.jpg "$DESTDIR"/
sleep 3600 HOUR=`date +%H`
done
Functions in script
18
What is Function ?
A function is a subroutine, a code block that implements a set of operations, a "black
box" that performs a specified task. Wherever there is repetitive code, when a task repeats
with only slight variations in procedure, then consider using a function.
19
Syntax of Function ?
function function_name {
command...
}
or
function_name () {
command...
}
20
Example of Function ?
21
Example of Function ?
22
23
24
25
26
27
28
29
30
31
32

More Related Content

What's hot

Bash script (mask off remix)
Bash script (mask off remix)Bash script (mask off remix)
Bash script (mask off remix)Elaine Yeung
 
Using the command line on macOS
Using the command line on macOSUsing the command line on macOS
Using the command line on macOSAdamFallon4
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsLuka Zakrajšek
 
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2Kazuho Oku
 
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJan Stamer
 
Hebrew Windows Cluster 2012 in a one slide diagram
Hebrew Windows Cluster 2012 in a one slide diagramHebrew Windows Cluster 2012 in a one slide diagram
Hebrew Windows Cluster 2012 in a one slide diagramG M
 
Mashup your life with Yahoo Pipes
Mashup your life with Yahoo PipesMashup your life with Yahoo Pipes
Mashup your life with Yahoo PipesCristiano Betta
 
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystembetterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystemJan Stamer
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with PerlKazuho Oku
 

What's hot (20)

Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyists
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Let's Go-lang
Let's Go-langLet's Go-lang
Let's Go-lang
 
Proces
ProcesProces
Proces
 
Bash script (mask off remix)
Bash script (mask off remix)Bash script (mask off remix)
Bash script (mask off remix)
 
Using the command line on macOS
Using the command line on macOSUsing the command line on macOS
Using the command line on macOS
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math ops
 
Defer, Panic, Recover
Defer, Panic, RecoverDefer, Panic, Recover
Defer, Panic, Recover
 
Forkexpe
ForkexpeForkexpe
Forkexpe
 
Sender
SenderSender
Sender
 
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2
 
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
 
3 rd animation
3 rd animation3 rd animation
3 rd animation
 
Rust言語紹介
Rust言語紹介Rust言語紹介
Rust言語紹介
 
Hebrew Windows Cluster 2012 in a one slide diagram
Hebrew Windows Cluster 2012 in a one slide diagramHebrew Windows Cluster 2012 in a one slide diagram
Hebrew Windows Cluster 2012 in a one slide diagram
 
Mashup your life with Yahoo Pipes
Mashup your life with Yahoo PipesMashup your life with Yahoo Pipes
Mashup your life with Yahoo Pipes
 
Unix2
Unix2Unix2
Unix2
 
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystembetterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
 
Note
NoteNote
Note
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
 

Viewers also liked

Current Trends And Technologies Ch-13 (E.M)
Current Trends And Technologies Ch-13 (E.M)Current Trends And Technologies Ch-13 (E.M)
Current Trends And Technologies Ch-13 (E.M)MohsinHusenManasiya
 
Advanced Scripting (Ch-8) English Medium Std-11
Advanced Scripting (Ch-8) English Medium Std-11Advanced Scripting (Ch-8) English Medium Std-11
Advanced Scripting (Ch-8) English Medium Std-11MohsinHusenManasiya
 
Advanced Scripting (Ch-8) Gujarati Medium Std-11
Advanced Scripting (Ch-8) Gujarati Medium Std-11Advanced Scripting (Ch-8) Gujarati Medium Std-11
Advanced Scripting (Ch-8) Gujarati Medium Std-11MohsinHusenManasiya
 
Vim Editor And Basic Scripting Gujarati Medium (Ch-7)
Vim Editor And Basic Scripting Gujarati Medium (Ch-7)Vim Editor And Basic Scripting Gujarati Medium (Ch-7)
Vim Editor And Basic Scripting Gujarati Medium (Ch-7)MohsinHusenManasiya
 
Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)MohsinHusenManasiya
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...SlideShare
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksSlideShare
 
Introduction to SlideShare for Businesses
Introduction to SlideShare for BusinessesIntroduction to SlideShare for Businesses
Introduction to SlideShare for BusinessesSlideShare
 
Lead Generation on SlideShare: A How-to Guide
Lead Generation on SlideShare: A How-to GuideLead Generation on SlideShare: A How-to Guide
Lead Generation on SlideShare: A How-to GuideSlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShareSlideShare
 

Viewers also liked (10)

Current Trends And Technologies Ch-13 (E.M)
Current Trends And Technologies Ch-13 (E.M)Current Trends And Technologies Ch-13 (E.M)
Current Trends And Technologies Ch-13 (E.M)
 
Advanced Scripting (Ch-8) English Medium Std-11
Advanced Scripting (Ch-8) English Medium Std-11Advanced Scripting (Ch-8) English Medium Std-11
Advanced Scripting (Ch-8) English Medium Std-11
 
Advanced Scripting (Ch-8) Gujarati Medium Std-11
Advanced Scripting (Ch-8) Gujarati Medium Std-11Advanced Scripting (Ch-8) Gujarati Medium Std-11
Advanced Scripting (Ch-8) Gujarati Medium Std-11
 
Vim Editor And Basic Scripting Gujarati Medium (Ch-7)
Vim Editor And Basic Scripting Gujarati Medium (Ch-7)Vim Editor And Basic Scripting Gujarati Medium (Ch-7)
Vim Editor And Basic Scripting Gujarati Medium (Ch-7)
 
Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 
Introduction to SlideShare for Businesses
Introduction to SlideShare for BusinessesIntroduction to SlideShare for Businesses
Introduction to SlideShare for Businesses
 
Lead Generation on SlideShare: A How-to Guide
Lead Generation on SlideShare: A How-to GuideLead Generation on SlideShare: A How-to Guide
Lead Generation on SlideShare: A How-to Guide
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 

Similar to Advanced Scripting - 2 (Ch-8)

Similar to Advanced Scripting - 2 (Ch-8) (20)

Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
34-shell-programming.ppt
34-shell-programming.ppt34-shell-programming.ppt
34-shell-programming.ppt
 
Shell programming
Shell programmingShell programming
Shell programming
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Chap06
Chap06Chap06
Chap06
 
Shell Scripting crash course.pdf
Shell Scripting crash course.pdfShell Scripting crash course.pdf
Shell Scripting crash course.pdf
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
Intro commandline
Intro commandlineIntro commandline
Intro commandline
 
Iteration
IterationIteration
Iteration
 
UNIX.ppt
UNIX.pptUNIX.ppt
UNIX.ppt
 
Shell Script Tutorial
Shell Script TutorialShell Script Tutorial
Shell Script Tutorial
 
101 apend. scripting, crond, atd
101 apend. scripting, crond, atd101 apend. scripting, crond, atd
101 apend. scripting, crond, atd
 
Unix
UnixUnix
Unix
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
3.1.c apend scripting, crond, atd
3.1.c apend   scripting, crond, atd3.1.c apend   scripting, crond, atd
3.1.c apend scripting, crond, atd
 
Repetition Structures
Repetition StructuresRepetition Structures
Repetition Structures
 
Licão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationLicão 12 decision loops - statement iteration
Licão 12 decision loops - statement iteration
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
 

More from MohsinHusenManasiya (20)

Ch - 01 [Eng-11] Chapter -1
Ch - 01 [Eng-11] Chapter -1Ch - 01 [Eng-11] Chapter -1
Ch - 01 [Eng-11] Chapter -1
 
Storage unit
Storage unitStorage unit
Storage unit
 
Satelite
SateliteSatelite
Satelite
 
RFID
RFIDRFID
RFID
 
QR CODE
QR CODEQR CODE
QR CODE
 
Qr
QrQr
Qr
 
Qr codes
Qr codesQr codes
Qr codes
 
Teamviewr
TeamviewrTeamviewr
Teamviewr
 
Malware
MalwareMalware
Malware
 
Q 1
Q 1Q 1
Q 1
 
Ppi
PpiPpi
Ppi
 
Nfc
NfcNfc
Nfc
 
Network
NetworkNetwork
Network
 
Mobile processor
Mobile processorMobile processor
Mobile processor
 
Lasik eye surgery
Lasik eye surgeryLasik eye surgery
Lasik eye surgery
 
Iris
IrisIris
Iris
 
Internet vs intranet vs extranet
Internet vs intranet vs extranetInternet vs intranet vs extranet
Internet vs intranet vs extranet
 
Ingestible robots
Ingestible robotsIngestible robots
Ingestible robots
 
I3 vs i5 vs i7
I3 vs i5 vs i7I3 vs i5 vs i7
I3 vs i5 vs i7
 
How does wireless inductive charging work
How does wireless inductive charging workHow does wireless inductive charging work
How does wireless inductive charging work
 

Recently uploaded

COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesSHIVANANDaRV
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 

Recently uploaded (20)

COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 

Advanced Scripting - 2 (Ch-8)

  • 2. 2 What is Handling Repetition ? Handling Repetition is control structure also known as looping control structure,Handling Repetition is control structure also known as looping control structure, is a type of control structure in programming languages that is used to simplify repetitive oris a type of control structure in programming languages that is used to simplify repetitive or recursive tasks operation.recursive tasks operation.
  • 3. Delete zero sized files in system.Delete zero sized files in system. 3 Code for write a script to delete zero sized files from a given directory (and all its subdirectories) in Unix / Linux / Ubuntu Code for write a script to delete zero sized files from a given directory (and all its subdirectories) in Unix / Linux / Ubuntu
  • 4. 4
  • 5. 5 Script 19 Handling Repetition is control structure also known as looping control structure,Handling Repetition is control structure also known as looping control structure, is a type of control structure in programming languages that is used to simplify repetitive oris a type of control structure in programming languages that is used to simplify repetitive or recursive tasks operation.recursive tasks operation.
  • 6. 6 Repetitive tasks 1.1. The for loopThe for loop 2.2. The while loopThe while loop 3.3. The until loopThe until loop
  • 7. 7 The for loopThe for loop The for loop is the first of the three shell looping constructs. This loop allows for specification of a list of values. A list of commands is executed for each value in the list.
  • 8. 8 for loop Syntaxfor loop Syntax
  • 9. 9 for loop Examplefor loop Example $ cat for1.sh i=1 for day in Mon Tue Wed Thu Fri do echo "Weekday $((i++)) : $day" done $ ./for1.sh Weekday 1 : Mon Weekday 2 : Tue Weekday 3 : Wed Weekday 4 : Thu Weekday 5 : Fri
  • 10. 10 The while loopThe while loop The while construct allows for repetitive execution of a list of commands, as long as the command controlling the while loop executes successfully (exit status of zero) The while construct allows for repetitive execution of a list of commands, as long as the command controlling the while loop executes successfully (exit status of zero)
  • 11. 11 The while loopThe while loop
  • 13. 13 while loop Examplewhile loop Example a=0 while [ $a -lt 10 ] do echo $a a=`expr $a + 1` done
  • 14. 14 The until loopThe until loop
  • 15. 15 until loop Syntaxuntil loop Syntax until <TEST-COMMAND>; do CONSEQUENT - COMMANDS; done
  • 16. 16 until loop Exampleuntil loop Example until [ $DISKFUL -ge "90" ]; do DATE=`date +%Y%m%d` HOUR=`date +%H` mkdir $WEBDIR/"$DATE" while [ $HOUR -ne "00" ]; do DESTDIR=$WEBDIR/"$DATE"/"$HOUR" mkdir "$DESTDIR" mv $PICDIR/*.jpg "$DESTDIR"/ sleep 3600 HOUR=`date +%H` done
  • 18. 18 What is Function ? A function is a subroutine, a code block that implements a set of operations, a "black box" that performs a specified task. Wherever there is repetitive code, when a task repeats with only slight variations in procedure, then consider using a function.
  • 19. 19 Syntax of Function ? function function_name { command... } or function_name () { command... }
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32