SlideShare a Scribd company logo
1 of 1
18IS33-UNIX and Shell Programming (Scheme and Solution) Page 8
Signature of the QuestionPaperSetter:
:
Signature of Scrutinizer
Subject Titles: UNIX and Shell Programming. Subject Code: 18IS33
Q.No. Solutions Marks
Allotted
8.a) THE BEGIN AND END SECTIONS:Awk statements are usully applied to all lines selected by
the address, and if there are no addresses, then they are applied to every line of input. But, if you
have to print something before processing the first line, for example, a heading, then the BEGIN
section can be used gainfully. Similarly, the end section useful in printing some totals after
processing is over.
The BEGIN and END sections are optional and take the form
BEGIN {action}
END {action}
6M
8.b) i) split(stg, arr, ch): it breaks up a string stg on the delimiter ch and stores the fields in an array
ii) substr (stg, m, n): it extracts a substring from a string stg. m represents the starting point of
extraction and n indicates the number of characters to be extracted.
iii) length: it determines the length of its arguments, and if no argument is present, the enire
line is assumed to be the argument.
iv) index(s1, s2): it determines the position of a string s2within a larger string s1.
8M
8.c) The Comparison Operators : awk provides the comparison operators like >, <, >=, <= ,==, !=.
~ and !~ : The Regular Expression Operators:
Variables and Expressions: Variables and expressions can be used with awk as used with any
programming language. Here, expression consists of strings, numbers and variables combined by
operators.
6M
9.a) String HandlingFunctionsin perl
length :-determines the length of its argument.
index(s1, s2) :-determines the position of a string s2 within string s1.
substr(str,m,n) :- extracts a substring from a string str, m represents the starting point of
extraction and n indicates the number of characters to be extracted.
uc(str) :- converts all the letters of str into uppercase.
ucfirst(str): converts first letter of all leading words into uppercase.
reverse(str):- reverses the characters contained in string str.
8M
9.b) #!usr/bin/perl
print "Perl Script to Print Leap years!nn";
print "Enter Start Year: ";
$startYear=<STDIN>;
print "Enter End Year: ";
$endYear=<STDIN>;
print "Leap years are:n";
# loop through between thestart and end year
for($i=$startYear; $i <= $endYear; $i++){
if( (0 == $i % 4) && (0 != $i % 100) || (0 == $i % 400) ){
print "${i}n";
}
6M

More Related Content

What's hot

What's hot (20)

More Pointers and Arrays
More Pointers and ArraysMore Pointers and Arrays
More Pointers and Arrays
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
Google technical-subjects-placement-papers
Google technical-subjects-placement-papersGoogle technical-subjects-placement-papers
Google technical-subjects-placement-papers
 
A nice 64-bit error in C
A  nice 64-bit error in CA  nice 64-bit error in C
A nice 64-bit error in C
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Unit 4
Unit 4Unit 4
Unit 4
 
Presention programming
Presention programmingPresention programming
Presention programming
 
Pointers in c v5 12102017 1
Pointers in c v5 12102017 1Pointers in c v5 12102017 1
Pointers in c v5 12102017 1
 
Lecture one
Lecture oneLecture one
Lecture one
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Unit v
Unit vUnit v
Unit v
 
Arrays and Pointers
Arrays and PointersArrays and Pointers
Arrays and Pointers
 
Rust - Fernando Borretti
Rust - Fernando BorrettiRust - Fernando Borretti
Rust - Fernando Borretti
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
Pointers
PointersPointers
Pointers
 
Arrays In General
Arrays In GeneralArrays In General
Arrays In General
 
Mbd2
Mbd2Mbd2
Mbd2
 
Highlevel assemly
Highlevel assemlyHighlevel assemly
Highlevel assemly
 

Similar to 8 (20)

STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Lecture 05 2017
Lecture 05 2017Lecture 05 2017
Lecture 05 2017
 
Ocs752 unit 3
Ocs752   unit 3Ocs752   unit 3
Ocs752 unit 3
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 
Strings part2
Strings part2Strings part2
Strings part2
 
strings
stringsstrings
strings
 
String notes
String notesString notes
String notes
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
 
Strings
StringsStrings
Strings
 
Console I/o & basics of array and strings.pptx
Console I/o & basics of array and strings.pptxConsole I/o & basics of array and strings.pptx
Console I/o & basics of array and strings.pptx
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Strings
StringsStrings
Strings
 
U4.ppt
U4.pptU4.ppt
U4.ppt
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Unitii string
Unitii stringUnitii string
Unitii string
 
lecture-5 string.pptx
lecture-5 string.pptxlecture-5 string.pptx
lecture-5 string.pptx
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
 
string in C
string in Cstring in C
string in C
 

More from satishbb (7)

10
1010
10
 
9
99
9
 
7
77
7
 
5
55
5
 
4
44
4
 
3
33
3
 
2
22
2
 

Recently uploaded

Call me @ 9892124323 Call Girl in Andheri East With Free Home Delivery
Call me @ 9892124323 Call Girl in Andheri East With Free Home DeliveryCall me @ 9892124323 Call Girl in Andheri East With Free Home Delivery
Call me @ 9892124323 Call Girl in Andheri East With Free Home DeliveryPooja Nehwal
 
Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...
Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...
Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...Delhi Call girls
 
Introduction of Basic of Paint Technology
Introduction of Basic of Paint TechnologyIntroduction of Basic of Paint Technology
Introduction of Basic of Paint TechnologyRaghavendraMishra19
 
How To Troubleshoot Mercedes Blind Spot Assist Inoperative Error
How To Troubleshoot Mercedes Blind Spot Assist Inoperative ErrorHow To Troubleshoot Mercedes Blind Spot Assist Inoperative Error
How To Troubleshoot Mercedes Blind Spot Assist Inoperative ErrorAndres Auto Service
 
Innovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC TechnologyInnovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC Technologyquickpartslimitlessm
 
BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024AHOhOops1
 
VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...Suhani Kapoor
 
What Causes BMW Chassis Stabilization Malfunction Warning To Appear
What Causes BMW Chassis Stabilization Malfunction Warning To AppearWhat Causes BMW Chassis Stabilization Malfunction Warning To Appear
What Causes BMW Chassis Stabilization Malfunction Warning To AppearJCL Automotive
 
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp NumberVip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Numberkumarajju5765
 
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls  Size E6 (O525547819) Call Girls In DubaiDubai Call Girls  Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubaikojalkojal131
 
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...shivangimorya083
 
新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一
新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一
新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一nsrmw5ykn
 
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhiHauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhiHot Call Girls In Sector 58 (Noida)
 
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...shivangimorya083
 
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂Hot Call Girls In Sector 58 (Noida)
 
The 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journeyThe 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journeyHyundai Motor Group
 
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kasba 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Roomdivyansh0kumar0
 
(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...
(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...
(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...Hot Call Girls In Sector 58 (Noida)
 
Electronic Vehicle (EV) Industry Challenges
Electronic Vehicle (EV) Industry ChallengesElectronic Vehicle (EV) Industry Challenges
Electronic Vehicle (EV) Industry Challengesmarketingmangosemi
 

Recently uploaded (20)

Call me @ 9892124323 Call Girl in Andheri East With Free Home Delivery
Call me @ 9892124323 Call Girl in Andheri East With Free Home DeliveryCall me @ 9892124323 Call Girl in Andheri East With Free Home Delivery
Call me @ 9892124323 Call Girl in Andheri East With Free Home Delivery
 
Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...
Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...
Call Girls in Malviya Nagar Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts Ser...
 
Introduction of Basic of Paint Technology
Introduction of Basic of Paint TechnologyIntroduction of Basic of Paint Technology
Introduction of Basic of Paint Technology
 
How To Troubleshoot Mercedes Blind Spot Assist Inoperative Error
How To Troubleshoot Mercedes Blind Spot Assist Inoperative ErrorHow To Troubleshoot Mercedes Blind Spot Assist Inoperative Error
How To Troubleshoot Mercedes Blind Spot Assist Inoperative Error
 
Innovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC TechnologyInnovating Manufacturing with CNC Technology
Innovating Manufacturing with CNC Technology
 
BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024BLUE VEHICLES the kids picture show 2024
BLUE VEHICLES the kids picture show 2024
 
Stay Cool and Compliant: Know Your Window Tint Laws Before You Tint
Stay Cool and Compliant: Know Your Window Tint Laws Before You TintStay Cool and Compliant: Know Your Window Tint Laws Before You Tint
Stay Cool and Compliant: Know Your Window Tint Laws Before You Tint
 
VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Jamshedpur Deepika 8250192130 Independent Escort Se...
 
What Causes BMW Chassis Stabilization Malfunction Warning To Appear
What Causes BMW Chassis Stabilization Malfunction Warning To AppearWhat Causes BMW Chassis Stabilization Malfunction Warning To Appear
What Causes BMW Chassis Stabilization Malfunction Warning To Appear
 
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp NumberVip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
Vip Hot Call Girls 🫤 Mahipalpur ➡️ 9711199171 ➡️ Delhi 🫦 Whatsapp Number
 
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls  Size E6 (O525547819) Call Girls In DubaiDubai Call Girls  Size E6 (O525547819) Call Girls In Dubai
Dubai Call Girls Size E6 (O525547819) Call Girls In Dubai
 
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
 
新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一
新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一
新南威尔士大学毕业证(UNSW毕业证)成绩单原版一比一
 
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhiHauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
Hauz Khas Call Girls ☎ 7042364481 independent Escorts Service in delhi
 
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
Hot And Sexy 🥵 Call Girls Delhi Daryaganj {9711199171} Ira Malik High class G...
 
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
 
The 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journeyThe 10th anniversary, Hyundai World Rally Team's amazing journey
The 10th anniversary, Hyundai World Rally Team's amazing journey
 
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kasba 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kasba 👉 8250192130 Available With Room
 
(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...
(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...
(COD) ̄Young Call Girls In Dwarka , New Delhi꧁❤ 7042364481❤꧂ Escorts Service i...
 
Electronic Vehicle (EV) Industry Challenges
Electronic Vehicle (EV) Industry ChallengesElectronic Vehicle (EV) Industry Challenges
Electronic Vehicle (EV) Industry Challenges
 

8

  • 1. 18IS33-UNIX and Shell Programming (Scheme and Solution) Page 8 Signature of the QuestionPaperSetter: : Signature of Scrutinizer Subject Titles: UNIX and Shell Programming. Subject Code: 18IS33 Q.No. Solutions Marks Allotted 8.a) THE BEGIN AND END SECTIONS:Awk statements are usully applied to all lines selected by the address, and if there are no addresses, then they are applied to every line of input. But, if you have to print something before processing the first line, for example, a heading, then the BEGIN section can be used gainfully. Similarly, the end section useful in printing some totals after processing is over. The BEGIN and END sections are optional and take the form BEGIN {action} END {action} 6M 8.b) i) split(stg, arr, ch): it breaks up a string stg on the delimiter ch and stores the fields in an array ii) substr (stg, m, n): it extracts a substring from a string stg. m represents the starting point of extraction and n indicates the number of characters to be extracted. iii) length: it determines the length of its arguments, and if no argument is present, the enire line is assumed to be the argument. iv) index(s1, s2): it determines the position of a string s2within a larger string s1. 8M 8.c) The Comparison Operators : awk provides the comparison operators like >, <, >=, <= ,==, !=. ~ and !~ : The Regular Expression Operators: Variables and Expressions: Variables and expressions can be used with awk as used with any programming language. Here, expression consists of strings, numbers and variables combined by operators. 6M 9.a) String HandlingFunctionsin perl length :-determines the length of its argument. index(s1, s2) :-determines the position of a string s2 within string s1. substr(str,m,n) :- extracts a substring from a string str, m represents the starting point of extraction and n indicates the number of characters to be extracted. uc(str) :- converts all the letters of str into uppercase. ucfirst(str): converts first letter of all leading words into uppercase. reverse(str):- reverses the characters contained in string str. 8M 9.b) #!usr/bin/perl print "Perl Script to Print Leap years!nn"; print "Enter Start Year: "; $startYear=<STDIN>; print "Enter End Year: "; $endYear=<STDIN>; print "Leap years are:n"; # loop through between thestart and end year for($i=$startYear; $i <= $endYear; $i++){ if( (0 == $i % 4) && (0 != $i % 100) || (0 == $i % 400) ){ print "${i}n"; } 6M