SlideShare a Scribd company logo
1 of 7
Download to read offline
Dr. D. P.
Mishra
Digitally signed by Dr. D. P. Mishra
DN: cn=Dr. D. P. Mishra, o=durg,
ou=BIT, email=dpmishra@bitdurg.
ac.in, c=IN
Date: 2023.03.13 12:39:50 +05'30'
#!/bin/sh
# This script performs basic mathematical operations
echo "Enter the first number: "
read num1
echo "Enter the second number: "
read num2
# Addition
add=$((num1 + num2))
echo "The sum of $num1 and $num2 is $add.โ€œ
# Subtraction
sub=$((num1 - num2))
echo "The difference of $num1 and $num2 is $sub."
# Multiplication
mul=$((num1 * num2))
echo "The product of $num1 and $num2 is
$mul."
# Division
if [ $num2 -ne 0 ]
then
div=$((num1 / num2))
echo "The quotient of $num1 and $num2
is $div."
else
echo "Cannot divide by zero."
fi
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
5.1- Shell Script for performing basic
mathematical operations
#!/bin/sh
# This script swaps the values of
two numbers using a temporary
variable
echo "Enter the first number: "
read num1
echo "Enter the second number: "
read num2
echo "Before swapping, num1 is
$num1 and num2 is $num2."
# Swap the values of num1 and num2
using a temporary variable
temp=$num1
num1=$num2
num2=$temp
echo "After swapping, num1 is $num1
and num2 is $num2."
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
5.2- Shell Script for Swapping values of two
numbers using temporary variables
#!/bin/sh
# This script swaps two numbers
without using a temporary variable
echo "Enter the first number: "
read num1
echo "Enter the second number: "
read num2
echo "Before swapping, num1 is
$num1 and num2 is $num2."
# Swap the values of num1 and num2
without a temporary variable
num1=$((num1 + num2))
num2=$((num1 - num2))
num1=$((num1 - num2))
echo "After swapping, num1 is $num1
and num2 is $num2."
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
5.3- Shell Script to swap two numbers
without Temporary Variables
5.4- Shell Script for determining whether
number is even or odd
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
#!/bin/sh
# This script determines whether a number is even or odd
echo "Enter a number: "
read num
if [ $((num % 2)) -eq 0 ]
then
echo "$num is even."
else
echo "$num is odd."
fi
5.5:Task/Assignment
โ€ข Write a shell script to input marks of five subjects Physics, Chemistry,
Biology, Mathematics and Computer. Calculate percentage and grade
according to following logic:
โ€ข Percentage >= 90% : Grade A,
โ€ข Percentage >= 80% : Grade B,
โ€ข Percentage >= 70% : Grade C,
โ€ข Percentage >=60% . Grade D,
โ€ข Percentage >= 40% : Grade E,
โ€ข Percentage < 40% : Grade F.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Shell Programs

More Related Content

Similar to Basic Shell Programs

PRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptxPRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptxAbhinavGupta257043
ย 
Avoiding Hardware Aliasing
Avoiding Hardware AliasingAvoiding Hardware Aliasing
Avoiding Hardware AliasingPeter Breuer
ย 
cluster(python)
cluster(python)cluster(python)
cluster(python)Noriyuki Kojima
ย 
project 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docxproject 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docxbriancrawford30935
ย 
#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(troutmanboris
ย 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlideharman kaur
ย 
Introduction to base shell scripting
Introduction to base shell scriptingIntroduction to base shell scripting
Introduction to base shell scriptingZeeshan Iqbal
ย 
Programs.doc
Programs.docPrograms.doc
Programs.docArnabNath30
ย 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdfArnabNath30
ย 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfsagar414433
ย 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfsagar414433
ย 
ECE-PYTHON.docx
ECE-PYTHON.docxECE-PYTHON.docx
ECE-PYTHON.docxChaithanya89350
ย 
Teeing Up Python - Code Golf
Teeing Up Python - Code GolfTeeing Up Python - Code Golf
Teeing Up Python - Code GolfYelp Engineering
ย 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
ย 
C programs
C programsC programs
C programsMinu S
ย 

Similar to Basic Shell Programs (18)

PRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptxPRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptx
ย 
Avoiding Hardware Aliasing
Avoiding Hardware AliasingAvoiding Hardware Aliasing
Avoiding Hardware Aliasing
ย 
cluster(python)
cluster(python)cluster(python)
cluster(python)
ย 
project 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docxproject 6cards.pyimport randomclass Card( object ).docx
project 6cards.pyimport randomclass Card( object ).docx
ย 
#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(
ย 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
ย 
No comment
No commentNo comment
No comment
ย 
Introduction to base shell scripting
Introduction to base shell scriptingIntroduction to base shell scripting
Introduction to base shell scripting
ย 
Programs.doc
Programs.docPrograms.doc
Programs.doc
ย 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
ย 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
ย 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
ย 
ECE-PYTHON.docx
ECE-PYTHON.docxECE-PYTHON.docx
ECE-PYTHON.docx
ย 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
ย 
Python
PythonPython
Python
ย 
Teeing Up Python - Code Golf
Teeing Up Python - Code GolfTeeing Up Python - Code Golf
Teeing Up Python - Code Golf
ย 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
ย 
C programs
C programsC programs
C programs
ย 

More from BIT DURG

HTML_DOM
HTML_DOMHTML_DOM
HTML_DOMBIT DURG
ย 
JavaScript
JavaScriptJavaScript
JavaScriptBIT DURG
ย 
Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWWBIT DURG
ย 
Computer Networks
Computer NetworksComputer Networks
Computer NetworksBIT DURG
ย 
Computer Basics
Computer Basics Computer Basics
Computer Basics BIT DURG
ย 
ISDN & ATM
ISDN & ATMISDN & ATM
ISDN & ATMBIT DURG
ย 
Transport Control Protocol
Transport Control ProtocolTransport Control Protocol
Transport Control ProtocolBIT DURG
ย 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing ProtocolsBIT DURG
ย 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdfBIT DURG
ย 
Intternetworking With TCP/IP
Intternetworking With TCP/IPIntternetworking With TCP/IP
Intternetworking With TCP/IPBIT DURG
ย 
Computer Network Basics
Computer Network BasicsComputer Network Basics
Computer Network BasicsBIT DURG
ย 
MySQL
MySQL MySQL
MySQL BIT DURG
ย 
Types of Linux Shells
Types of Linux Shells Types of Linux Shells
Types of Linux Shells BIT DURG
ย 
File Access Permission
File Access PermissionFile Access Permission
File Access PermissionBIT DURG
ย 
Filters & Vi Editor
Filters & Vi EditorFilters & Vi Editor
Filters & Vi EditorBIT DURG
ย 
Basic Linux Commands
Basic Linux CommandsBasic Linux Commands
Basic Linux CommandsBIT DURG
ย 
Linux Installation
Linux InstallationLinux Installation
Linux InstallationBIT DURG
ย 
Basics of GNU & Linux
Basics of GNU & LinuxBasics of GNU & Linux
Basics of GNU & LinuxBIT DURG
ย 
National youth day
National youth dayNational youth day
National youth dayBIT DURG
ย 
Visual Basic Tutorials
Visual Basic TutorialsVisual Basic Tutorials
Visual Basic TutorialsBIT DURG
ย 

More from BIT DURG (20)

HTML_DOM
HTML_DOMHTML_DOM
HTML_DOM
ย 
JavaScript
JavaScriptJavaScript
JavaScript
ย 
Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWW
ย 
Computer Networks
Computer NetworksComputer Networks
Computer Networks
ย 
Computer Basics
Computer Basics Computer Basics
Computer Basics
ย 
ISDN & ATM
ISDN & ATMISDN & ATM
ISDN & ATM
ย 
Transport Control Protocol
Transport Control ProtocolTransport Control Protocol
Transport Control Protocol
ย 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing Protocols
ย 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdf
ย 
Intternetworking With TCP/IP
Intternetworking With TCP/IPIntternetworking With TCP/IP
Intternetworking With TCP/IP
ย 
Computer Network Basics
Computer Network BasicsComputer Network Basics
Computer Network Basics
ย 
MySQL
MySQL MySQL
MySQL
ย 
Types of Linux Shells
Types of Linux Shells Types of Linux Shells
Types of Linux Shells
ย 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
ย 
Filters & Vi Editor
Filters & Vi EditorFilters & Vi Editor
Filters & Vi Editor
ย 
Basic Linux Commands
Basic Linux CommandsBasic Linux Commands
Basic Linux Commands
ย 
Linux Installation
Linux InstallationLinux Installation
Linux Installation
ย 
Basics of GNU & Linux
Basics of GNU & LinuxBasics of GNU & Linux
Basics of GNU & Linux
ย 
National youth day
National youth dayNational youth day
National youth day
ย 
Visual Basic Tutorials
Visual Basic TutorialsVisual Basic Tutorials
Visual Basic Tutorials
ย 

Recently uploaded

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7Call Girls in Nagpur High Profile Call Girls
ย 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
ย 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
ย 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
ย 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
ย 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
ย 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Standamitlee9823
ย 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
ย 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
ย 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
ย 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
ย 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
ย 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
ย 

Recently uploaded (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
ย 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
ย 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
ย 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
ย 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
ย 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
ย 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
ย 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
ย 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
ย 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
ย 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
ย 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
ย 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
ย 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
ย 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
ย 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
ย 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
ย 

Basic Shell Programs

  • 1. Dr. D. P. Mishra Digitally signed by Dr. D. P. Mishra DN: cn=Dr. D. P. Mishra, o=durg, ou=BIT, email=dpmishra@bitdurg. ac.in, c=IN Date: 2023.03.13 12:39:50 +05'30'
  • 2. #!/bin/sh # This script performs basic mathematical operations echo "Enter the first number: " read num1 echo "Enter the second number: " read num2 # Addition add=$((num1 + num2)) echo "The sum of $num1 and $num2 is $add.โ€œ # Subtraction sub=$((num1 - num2)) echo "The difference of $num1 and $num2 is $sub." # Multiplication mul=$((num1 * num2)) echo "The product of $num1 and $num2 is $mul." # Division if [ $num2 -ne 0 ] then div=$((num1 / num2)) echo "The quotient of $num1 and $num2 is $div." else echo "Cannot divide by zero." fi Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg 5.1- Shell Script for performing basic mathematical operations
  • 3. #!/bin/sh # This script swaps the values of two numbers using a temporary variable echo "Enter the first number: " read num1 echo "Enter the second number: " read num2 echo "Before swapping, num1 is $num1 and num2 is $num2." # Swap the values of num1 and num2 using a temporary variable temp=$num1 num1=$num2 num2=$temp echo "After swapping, num1 is $num1 and num2 is $num2." Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg 5.2- Shell Script for Swapping values of two numbers using temporary variables
  • 4. #!/bin/sh # This script swaps two numbers without using a temporary variable echo "Enter the first number: " read num1 echo "Enter the second number: " read num2 echo "Before swapping, num1 is $num1 and num2 is $num2." # Swap the values of num1 and num2 without a temporary variable num1=$((num1 + num2)) num2=$((num1 - num2)) num1=$((num1 - num2)) echo "After swapping, num1 is $num1 and num2 is $num2." Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg 5.3- Shell Script to swap two numbers without Temporary Variables
  • 5. 5.4- Shell Script for determining whether number is even or odd Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg #!/bin/sh # This script determines whether a number is even or odd echo "Enter a number: " read num if [ $((num % 2)) -eq 0 ] then echo "$num is even." else echo "$num is odd." fi
  • 6. 5.5:Task/Assignment โ€ข Write a shell script to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate percentage and grade according to following logic: โ€ข Percentage >= 90% : Grade A, โ€ข Percentage >= 80% : Grade B, โ€ข Percentage >= 70% : Grade C, โ€ข Percentage >=60% . Grade D, โ€ข Percentage >= 40% : Grade E, โ€ข Percentage < 40% : Grade F. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg