1. Write a bash script to find GCD and LCM of two number.
Sample output:-
[zytham@s158519-vm scripts]$ sh pgssp1.sh
Enter first nuumber: 30
Enter second nuumber: 12
GCD of 30 and 12 is 6
LCM Of 30 and 12 is 60
Sample output:-
[zytham@s158519-vm scripts]$ sh pgssp11.sh 30 12
GCD of 30 and 12 is 6
LCM Of 30 and 12 is 60
Sample output:-
[zytham@s158519-vm scripts]$ sh fact.sh 5
factorial of number 5 is: 120
[zytham@s158519-vm scripts]$ sh fact.sh 13
factorial of number 13 is: 6227020800
4. WABS to find Binomial co-efficient of C(M,N) - value of the coefficient is given by the expression .
Sample output:-
[zytham@s158519-vm scripts]$ sh bico.sh 9 3
Binomial coefficient of C(9 3) is 60480
[zytham@s158519-vm scripts]$ sh bico.sh 8 4
Binomial coefficient of C(8 4) is 1680
[zytham@s158519-vm scripts]$ sh bico.sh 5 2
Binomial coefficient of C(5 2) is 60
Explanation:- Two input is passed from command line and that is propagated to function one by one to find factorial of M , N and M-N. Similar to bash script function also access passed argument as $1.
5. WABS to check numbe is perfect number or not - input passed from command line. ( A perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself )
Sample output:-
[zytham@s158519-vm scripts]$ sh perfect.sh 4
Not perfect
[zytham@s158519-vm scripts]$ sh perfect.sh 6
perfect
[zytham@s158519-vm scripts]$ sh perfect.sh 28
perfect
Sample output:-
[zytham@s158519-vm scripts]$ sh pgssp5.sh 5
1 1 2 3 5
[zytham@s158519-vm scripts]$ sh pgssp5.sh 8
1 1 2 3 5 8 13 21
[zytham@s158519-vm scripts]$ sh pgssp5.sh 9
1 1 2 3 5 8 13 21 34
7. WABS to check given number is Armstrong number or not.
Sample output:-
[zytham@s158519-vm scripts]$ sh ams.sh
Enter number : 153
153 is an armstrong number
[zytham@s158519-vm scripts]$ sh ams.sh
Enter number : 145
145 is not armstrong number
#!/bin/bash #find GCD and LCM of two numbers printf "Enter first nuumber: " read n1 printf "Enter second nuumber: " read n2 m=$n1 n=$n2 r=$n2 while [ $r -ne 0 ];do r=$(( n1%n2 )) if [ $r -eq 0 ];then break else ((n1=$n2)) ((n2=$r)) fi done printf "GCD of %d and %d is %d \n" $m $n $n2 printf "LCM Of %d and %d is %d \n" $m $n $((($m*$n)/$n2))
[zytham@s158519-vm scripts]$ sh pgssp1.sh
Enter first nuumber: 30
Enter second nuumber: 12
GCD of 30 and 12 is 6
LCM Of 30 and 12 is 60
2.Write a bash script to find GCD and LCM , provided input is passed via command line while executing this script (Pass command line arguments).
#!/bin/bash #find GCD of two numbers - input at runtime n1=$1 n2=$2 m=$n1 n=$n2 r=$n2 while [ $r -ne 0 ];do r=$(( n1%n2 )) if [ $r -eq 0 ];then #echo "GCD is $n2" break else ((n1=$n2)) ((n2=$r)) fi done printf "GCD of %d and %d is %d \n" $m $n $n2 printf "LCM Of %d and %d is %d \n" $m $n $((($m*$n)/$n2))
Sample output:-
[zytham@s158519-vm scripts]$ sh pgssp11.sh 30 12
GCD of 30 and 12 is 6
LCM Of 30 and 12 is 60
Explanation:- Here 30 and 12 are input to the bash script. It is accessed by script using $1 and $2. Here n1 is 30 and n2 os 20.
3. Write a bash script to find factorial of a number.
#!/bin/bash #find factorial of a number - input Passed as command line arguments n=$1 #Input passed via command line is stored in n fact=1 for i in `seq 1 $n`;do ((fact=fact*i)) done printf "factorial of number %d is: %d\n" $n $fact
Sample output:-
[zytham@s158519-vm scripts]$ sh fact.sh 5
factorial of number 5 is: 120
[zytham@s158519-vm scripts]$ sh fact.sh 13
factorial of number 13 is: 6227020800
4. WABS to find Binomial co-efficient of C(M,N) - value of the coefficient is given by the expression .
#!/bin/bash #find binomial coefficient of a two number - input Passed as command line arguments #function to find factorial of a number-Pass input argument to function function factorial { #echo $1 n=$1 fact=1 for i in `seq 1 $n`;do ((fact=fact*i)) done #printf "factorial of number %d is: %d\n" $n $fact } M=$1 N=$2 #call function for finding factorial of M factorial $1 fact1=$fact #call function for finding factorial N factorial $2 fact2=$fact dif=$(($m-$n)) #call function for finding factorial M-N factorial $dif fact3=$fact bico=$(($fact1/($fact2*fact3))) printf "Binomial coefficient of C($M $N) is %d \n" $bico
Sample output:-
[zytham@s158519-vm scripts]$ sh bico.sh 9 3
Binomial coefficient of C(9 3) is 60480
[zytham@s158519-vm scripts]$ sh bico.sh 8 4
Binomial coefficient of C(8 4) is 1680
[zytham@s158519-vm scripts]$ sh bico.sh 5 2
Binomial coefficient of C(5 2) is 60
Explanation:- Two input is passed from command line and that is propagated to function one by one to find factorial of M , N and M-N. Similar to bash script function also access passed argument as $1.
5. WABS to check numbe is perfect number or not - input passed from command line. ( A perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself )
#!/bin/bash #To check perfect number or not input via command line function perfectNumCheck { m=$1 iter=$(($m-1)) sum=0 for i in `seq 1 $iter`;do if (( $m%i==0)); then sum=$((sum + i)) fi done if [ $sum -eq $m ]; then echo "perfect" else echo "Not perfect" fi } perfectNumCheck $1
[zytham@s158519-vm scripts]$ sh perfect.sh 4
Not perfect
[zytham@s158519-vm scripts]$ sh perfect.sh 6
perfect
[zytham@s158519-vm scripts]$ sh perfect.sh 28
perfect
6. WABS to generate fibonacci numbers. (Inpiut passed via command line for number of fibonacci to be generated)
#!/bin/bash #fibbonacci generation - Input via command line regarding how many fibbonacci number function fibonacci { N=$1 a=0 b=1 if [ $N -eq 1 ]; then printf 1 else printf $((a+b)) printf "\t" while [ $N -ne 1 ];do sum=$(($a+$b)) printf $sum printf "\t" ((a=$b)) ((b=$sum)) ((N=$N-1)) done fi } fibonacci $1 printf "\n"
Sample output:-
[zytham@s158519-vm scripts]$ sh pgssp5.sh 5
1 1 2 3 5
[zytham@s158519-vm scripts]$ sh pgssp5.sh 8
1 1 2 3 5 8 13 21
[zytham@s158519-vm scripts]$ sh pgssp5.sh 9
1 1 2 3 5 8 13 21 34
7. WABS to check given number is Armstrong number or not.
#!/bin/bash #check armstrong number echo -n "Enter number : " read n input=$n sum=0 while [ $n -gt 0 ]; do (( rem= n%10 )) ((sum=$sum+(rem**3) )) # echo $sum ((n=n/10)) done if [ $input -eq $sum ];then echo "$input is an armstrong number " else echo "$input is not armstrong number "
Sample output:-
[zytham@s158519-vm scripts]$ sh ams.sh
Enter number : 153
153 is an armstrong number
[zytham@s158519-vm scripts]$ sh ams.sh
Enter number : 145
145 is not armstrong number
Tags:
Shell-scripting
Aivivu đại lý vé máy bay, tham khảo
ReplyDeletevé máy bay đi Mỹ khứ hồi
ve may bay tu my ve viet nam
khi nào có chuyến bay từ đức về việt nam
lịch bay hà nội moscow
ve may bay tu anh ve viet nam
vé máy bay từ pháp về việt nam
danh sách khách sạn cách ly ở tphcm
ve may bay chuyen gia nuoc ngoai sang Viet Nam
kars
ReplyDeletesinop
sakarya
ankara
çorum
C27
https://titandijital.com.tr/
ReplyDeletemersin parça eşya taşıma
osmaniye parça eşya taşıma
kırklareli parça eşya taşıma
tokat parça eşya taşıma
E766
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
5FVVS
van evden eve nakliyat
ReplyDeletesivas evden eve nakliyat
çankırı evden eve nakliyat
bartın evden eve nakliyat
erzincan evden eve nakliyat
SİBC
9BE70
ReplyDeleteSivas Parça Eşya Taşıma
Tokat Lojistik
Antep Parça Eşya Taşıma
Düzce Evden Eve Nakliyat
Kocaeli Lojistik
D9A06
ReplyDeleteBayburt Evden Eve Nakliyat
Elazığ Parça Eşya Taşıma
Bitlis Şehir İçi Nakliyat
Erzincan Şehir İçi Nakliyat
Ordu Evden Eve Nakliyat
Kırşehir Parça Eşya Taşıma
Kastamonu Evden Eve Nakliyat
Şırnak Evden Eve Nakliyat
Çanakkale Şehir İçi Nakliyat
B12EB
ReplyDeleteTekirdağ Evden Eve Nakliyat
Bayburt Evden Eve Nakliyat
Balıkesir Evden Eve Nakliyat
Silivri Evden Eve Nakliyat
Karaman Evden Eve Nakliyat
Kalıcı Makyaj
Şırnak Evden Eve Nakliyat
İzmir Evden Eve Nakliyat
Mersin Evden Eve Nakliyat
23523
ReplyDeletebinance referans kodu
9064B
ReplyDeleteindirim kodu %20
BFAF9
ReplyDeleteÇorum Sohbet Odaları
Mersin Mobil Sesli Sohbet
Kırşehir Görüntülü Sohbet Kızlarla
bartın rastgele sohbet
mobil sesli sohbet
Ankara Görüntülü Sohbet Uygulamaları Ücretsiz
Bartın Yabancı Görüntülü Sohbet Uygulamaları
yalova görüntülü sohbet siteleri ücretsiz
kütahya rastgele sohbet uygulaması
FFE1F
ReplyDeleteAptos Coin Hangi Borsada
Binance Referans Kodu
Pinterest Takipçi Satın Al
Mexc Borsası Güvenilir mi
Binance Para Kazanma
Binance Hesap Açma
Tiktok Beğeni Satın Al
Binance Referans Kodu
Youtube Beğeni Satın Al
499D7
ReplyDeleteLikee App Takipçi Satın Al
Bitcoin Nasıl Kazanılır
Onlyfans Beğeni Satın Al
Bitcoin Madenciliği Nedir
Paribu Borsası Güvenilir mi
Satoshi Coin Hangi Borsada
Ort Coin Hangi Borsada
Parasız Görüntülü Sohbet
MEME Coin Hangi Borsada
A135B
ReplyDeletekraken
kripto kanalları telegram
toptan sabun
sohbet canlı
telegram kripto
kaldıraç nasıl yapılır
kucoin
okex
en düşük komisyonlu kripto borsası
17E52
ReplyDeletetürk kripto telegram grupları
sohbet canlı
bibox
referans kodu binance
bitcoin seans saatleri
referans kimligi nedir
4g mobil proxy
en düşük komisyonlu kripto borsası
sohbet canlı
B8BE7
ReplyDeleteokex
kripto ne demek
btcturk
bitrue
coin nasıl alınır
kredi kartı ile kripto para alma
kaldıraç ne demek
canlı sohbet uygulamaları
binance ne demek
DD458
ReplyDelete----
----
----
----
----
----
----
----
matadorbet
4E5B2
ReplyDeleteVds Satın Al
Toptan Ürünler
vds
Telegram Abone
SEO Danışmanı
Silkroad Proxy
SEO Hizmeti
Twitter Reklam Verme
Tiktok Reklam Verme
E486F
ReplyDeletetiktok seo
btc forum
abone satın al
Offshore Hosting
facebook hesap satın al
takipci satin alma
adwords kupon satışı
Eticaret SEO
google 5 yıldız
5A217
ReplyDeleteSunucu Kiralama
İçerik Yazarı İş İlanları
Tiktok Para Kazanma
Netflix Film Önerileri
Dizi Önerileri
Twitter Para Kazanma
IPv4 Proxy Satın Al
Youtube Reklam Verme
Youtube İzlenme Satın Al
13E63
ReplyDeleteücretli show
show
görüntülü show
show
FF7FD
ReplyDeleteshow
show
ücretli show
görüntülü show
9DBA881440
ReplyDeletegörüntülü şov
görüntülü sex
sex hattı
sanal sex
sohbet hatti
seks hattı
cam şov
sanal seks
görüntülü seks
3F9289C80C
ReplyDeletebufalo içecek
ereksiyon hapı
maxman
geciktirici
stag
lifta
cialis
bufalo çikolata
kamagra
7CEA7636B3
ReplyDeleteviagra
yapay kızlık zarı
lifta
ücretli show
maxman
telegram görüntülü şov
delay
geciktirici
telegram show
00E4D635BB
ReplyDeletestag
sildegra
görüntülü şov
whatsapp görüntülü şov
cobra vega
themra macun
vega
bufalo içecek
telegram show