-
Notifications
You must be signed in to change notification settings - Fork 0
/
kosul-ifadeleri.sh
executable file
·90 lines (69 loc) · 1.88 KB
/
kosul-ifadeleri.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /bin/bash
# ---- IF KULLANIMI -----
# if[kosul]
# then
# durum
# fi
# (if, elif, else)
# ---- INT KARSILASIRMA -----
# -eq / esit ise / if [ "$a" -eq "$b" ] (equal)
# -ne / esit degil ise / if [ "$a" -ne "$b" ] (not equal)
# -gt / buyuk ise / if [ "$a" -gt "$b" ] (greater than)
# -ge / buyuk veya esit ise / if [ "$a" -ge "$b" ] (greater than or equal)
# -lt / kucuk ise / if [ "$a" -lt "$b" ] (less than)
# -le / kucuk veya esit ise / if [ "$a" -le "$b" ] (less than or equal)
# < / kucuk / if(( "$a" < "$b" ))
# <= / kucuk esit / if(( "$a" <= "$b" ))
# > / buyuk / if(( "$a" > "$b" ))
# >= / buyuk esit / if(( "$a" >= "$b" ))
# ---- STRING KARSILASTIRMA -----
# = / esit ise / if [ "$a" = "$b" ]
# == / esit ise / if [ "$a" == "$b" ]
# != / esit degil ise / if [ "$a" != "$b" ]
# < / kucuk / if [[ "$a" < "$b" ]] --> Alfabetik dizilime gore
# > / buyuk / if [[ "$a" > "$b" ]] --> Alfabetik dizilime gore
# ---- AND, OR OPERATORLERİ -----
# AND --> && (-a)
# OR --> || (-o)
# Dikkat edilmesi gereken bir diger sey if kullanırken aralarda bosluk birakilmasi gerekmektedir.
sayi=10
# Ornek-1
if [ $sayi -eq 10 ]
then
echo "Kosul dogru"
fi
# Ornek-2
if [ $sayi -ne 9 ]
then
echo "Kosul dogru-2"
fi
# Ornek-3
if (( $sayi != 9 ))
then
echo "Kosul dogru-3"
fi
# Ornek-4
deger=9
if (( $deger < 9 ))
then
echo "Deger 9'dan kucuktur"
elif (( $deger > 9 ))
then
echo "Deger 9'dan buyuk"
else
echo "Deger 9'a esit"
fi
# Ornek-5
ad=alperen
if [ $ad == "alperen" ]
then
echo "Isım Alperen'dir"
fi
# Ornek-6
yas=28
if [ "$yas" -gt 18 ] && [ "$yas" -lt 30 ] # if [ "$yas" -gt 18 -a "$yas" -lt 30 ], [[ "$yas" -gt 18 && "$yas" -lt 30 ]] --> ayni seydir
then
echo "Gecerli yas"
else
echo "Gecersiz yas"
fi