Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet209/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   205   206   207   208   209   210   211   212   ...   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)

[
 155 
]
Next, we set up a 
while
 loop. A 
while
 loop will continue until a condition is met. 
Here, we're telling it to execute the statements in the block over and over until 
$myvar
 
becomes equal to 
15
. In fact, a 
while
 loop can continue forever if you enter something 
incorrectly, which is known as an 
Infinite Loop
. An infinite loop is dangerous, and 
can cause your server to stop responding. If you used 
-ge 0
 instead, you would've 
created exactly that:
do
With 
do
, we're telling the 
for
 loop to prepare itself to start doing something:
    echo $myvar
Here, we're printing the current content of the 
$myvar
 variable—nothing surprising 
here:
    ((myvar++))
With this statement, we're using what's known as an incrementor to increase the 
value of our variable by 
1
. The double parenthesis tells the shell that we're doing an 
arithmetic operation, so the interpreter doesn't think that we're working with strings:
done
When we're done writing a 
while
 loop, we must close the block with 
done
. If you've 
typed the script properly, it should count from 
1
 to 
15
.
Another type of loop is a 
For Loop
. A 
for
 loop executes a statement for every item in 
a set. For example, you can have the 
for
 loop execute a command against every file 
in a directory. Consider this example:
#!/bin/bash
turtles='Donatello Leonardo Michelangelo Raphael'
for t in $turtles
do
    echo $t
done
Let's take a deeper look into what we've done here:
turtles='Donatello Leonardo Michelangelo Raphael'


Boosting Your Command-line Efficiency

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   205   206   207   208   209   210   211   212   ...   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