Arkadaslar simdi girilen bir sayinin tek mi cift mi oldugunu soyleyen bir script yapmak istedim. Bir sitedede bu islemi yaptigini soyleyen bir script verilmisti. O script calismiyordu. Bende kendi kendime bir script yazdim ama mantigini anlayamadim
Sitedeki script
#!/bin/bash
echo 0 ile 20 arasinda bir sayi secin
read sec
if [ $sec -lt 10 ]
then
echo Secilen sayi tek basamakli
else
echo Secilen sayi cift basamakli
fi
Benim yazdigim
#!/bin/bash
echo "Bir Sayı Giriniz"
read sec
if [[ $(( $sec % 2 )) == 1 ]]
then
echo "Girilen Sayı Tek Basamaklı"
else
echo "Girilen Sayı Çift Basamaklı"
fi
Sitedeki script
#!/bin/bash
echo 0 ile 20 arasinda bir sayi secin
read sec
if [ $sec -lt 10 ]
then
echo Secilen sayi tek basamakli
else
echo Secilen sayi cift basamakli
fi
Benim yazdigim
#!/bin/bash
echo "Bir Sayı Giriniz"
read sec
if [[ $(( $sec % 2 )) == 1 ]]
then
echo "Girilen Sayı Tek Basamaklı"
else
echo "Girilen Sayı Çift Basamaklı"
fi