Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet208/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   204   205   206   207   208   209   210   211   ...   482
Bog'liq
Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)

[
 154 
]
The 
-eq
 portion of the command is similar to 
==
 in most programming languages. It's 
checking to see whether the value is equal to something. Alternatively, we can use 
-ne
 (not equal), 
-gt
 (greater than), 
-ge
 (greater than or equal to), 
-lt
 (less than), and 
so on.
At this point, I recommend you take a break from reading to further practice 
scripting (practice is key to committing concepts to memory). Try the following 
challenges:
•  Ask the user to enter input, such as their age, and save it to a variable. If the 
user enters a number less than 30, tell them they're young. If the number is 
equal to or greater than 30, 
echo
 a statement telling them that they're old.
• 
Write a script that copies a file from one place to another. Make the script 
check to see whether that file exists first, and have an 
else
 statement printing 
an error if the file doesn't exist.
•  Think about any topic we've already worked on during this book, and 
attempt to automate it.
Now, let's take a look at another concept, which is looping. The basic idea behind 
looping is simply doing something repeatedly until a condition has been met. 
Consider the following example script:
#!/bin/bash
myvar=1
while [ $myvar -le 15 ] 
do 
    echo $myvar 
    ((myvar++)) 
done 
Let's go through the script line by line to understand what it's doing.
myvar=1 
With this new script, we're creating a control variable, called 
myvar
, and setting it 
equal to 
1
:
while [ $myvar -le 15 ]


Chapter 6

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   204   205   206   207   208   209   210   211   ...   482




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish