SlideShare a Scribd company logo
Universiteti “Aleksander Moisiu” Durres
Fakulteti i Teknologjisë së Informacionit
Dega: Teknologji Informacioni
Lenda: Linux
Tema: Script ne Bash Shell
DETYRE KURSI
Punoi: Durim Hysa
Besart Darsi
Klevis Cekani
Ky eshte nje Script i ndertuar ne Bash Shell.
Ky program gjeneron Mbledhjen Zbritjen, Shumezimin dhe Pjestimin e dy numrave me ane te
funksioneve.
Ne fillim behet futja e numrit te pare nga tastjera dhe me pas e numrit te dyte.
Kushti eshte qe te jene numra te plote dhe numri i dyte te jete me i madh se 0.
Kodi sebashku me shpjegimin e komandave
#!/bin/bash
# Sigurohuni që numri i parametrave të jetë 2
if [ $# -eq 0 ];then
# If eshte nje kusht ndersa $# sherben per kthimin e funksionit,0
eshte standarte qe lejon kodin te ekzekutohet me sukses. Nëse kodi i
mëparshëm i kthimit nuk ishte i barabartë me 0' ai do të pasohet me
then.
# read -p sherben per futjen e te dhnave nga tastjera.
read -p "Vendosni numrin e pare: " first
read -p "Vendosni numrin e dyte: " second
elif [ $# -eq 1 ];then
# elif eshte nje kusht qe duhet plotesuar per te vazhduar me numrin
tjeter.
first=$1
read -p "Vendosni numrin e dyte: " second
elif [ $# -eq 2 ];then
first=$1
second=$2
else
echo "numri i argumenteve duhet të jetë dy!"
exit 0
# exit 0 do te thote qe kodi qe kthen funksionin ne 0 ku 0 eshte
parameter
fi
# fi sherbenpermbylljene nje bllokuIF
# Përcaktoni nëse parametri i parë është një numër i plotë
if [[ $first =~ ^-?[0-9]+$ ]];then
if [ $first -eq 0 ];then
first=0
else
first=`echo $first | sed -r 's/^(-?)0+/1/'`
# SED është një redaktues i frrjedhës së tekstit. Mund të bëjë futje,
fshirje, kërkim dhe zëvendësim.
fi
else
echo "Argumenti duhet të jetë numër i plotë!"
exit 1
fi
# Përcakton nëse parametri i dytë është një numër i plotë dhe nëse
numër i plotë është jo-zero
if [[ $second =~ ^-?[0-9]+$ ]];then
[ $second -eq 0 ] && { echo "Numri i dyte nuk mund te jete 0";exit
102; }
second=`echo $second | sed -r 's/^(-?)0+/1/'`
else
echo "Argumenti duhet të jetë numër i plotë!"
exit 1
fi
ADD=$[first+second] # Behet mbledhja numrave
SUB=$[first-second] # Behet zbritja numrave
RID=$[first*second] # Behet shumezimi numrave
DIV=$[first/second] # Behet pjestimi numrave
# Behet afishimi rezultatit
echo "$first + $second = $ADD"
echo "$first - $second = $SUB"
echo "$first * $second = $RID"
echo "$first / $second = $DIV"
Rezultati

More Related Content

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Detyre Kursi - Script ne Bash Shell LINUX

  • 1. Universiteti “Aleksander Moisiu” Durres Fakulteti i Teknologjisë së Informacionit Dega: Teknologji Informacioni Lenda: Linux Tema: Script ne Bash Shell DETYRE KURSI Punoi: Durim Hysa Besart Darsi Klevis Cekani
  • 2. Ky eshte nje Script i ndertuar ne Bash Shell. Ky program gjeneron Mbledhjen Zbritjen, Shumezimin dhe Pjestimin e dy numrave me ane te funksioneve. Ne fillim behet futja e numrit te pare nga tastjera dhe me pas e numrit te dyte. Kushti eshte qe te jene numra te plote dhe numri i dyte te jete me i madh se 0. Kodi sebashku me shpjegimin e komandave #!/bin/bash # Sigurohuni që numri i parametrave të jetë 2 if [ $# -eq 0 ];then # If eshte nje kusht ndersa $# sherben per kthimin e funksionit,0 eshte standarte qe lejon kodin te ekzekutohet me sukses. Nëse kodi i mëparshëm i kthimit nuk ishte i barabartë me 0' ai do të pasohet me then. # read -p sherben per futjen e te dhnave nga tastjera. read -p "Vendosni numrin e pare: " first read -p "Vendosni numrin e dyte: " second elif [ $# -eq 1 ];then # elif eshte nje kusht qe duhet plotesuar per te vazhduar me numrin tjeter. first=$1 read -p "Vendosni numrin e dyte: " second elif [ $# -eq 2 ];then first=$1 second=$2
  • 3. else echo "numri i argumenteve duhet të jetë dy!" exit 0 # exit 0 do te thote qe kodi qe kthen funksionin ne 0 ku 0 eshte parameter fi # fi sherbenpermbylljene nje bllokuIF # Përcaktoni nëse parametri i parë është një numër i plotë if [[ $first =~ ^-?[0-9]+$ ]];then if [ $first -eq 0 ];then first=0 else first=`echo $first | sed -r 's/^(-?)0+/1/'` # SED është një redaktues i frrjedhës së tekstit. Mund të bëjë futje, fshirje, kërkim dhe zëvendësim. fi else echo "Argumenti duhet të jetë numër i plotë!" exit 1 fi # Përcakton nëse parametri i dytë është një numër i plotë dhe nëse numër i plotë është jo-zero if [[ $second =~ ^-?[0-9]+$ ]];then [ $second -eq 0 ] && { echo "Numri i dyte nuk mund te jete 0";exit 102; } second=`echo $second | sed -r 's/^(-?)0+/1/'`
  • 4. else echo "Argumenti duhet të jetë numër i plotë!" exit 1 fi ADD=$[first+second] # Behet mbledhja numrave SUB=$[first-second] # Behet zbritja numrave RID=$[first*second] # Behet shumezimi numrave DIV=$[first/second] # Behet pjestimi numrave # Behet afishimi rezultatit echo "$first + $second = $ADD" echo "$first - $second = $SUB" echo "$first * $second = $RID" echo "$first / $second = $DIV" Rezultati