Birmingham mumbai



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

[
 156 
]
Here, we're creating a list and populating it with names. Each name is one item in 
the list. We're calling this list 
turtles
. We can see the contents of this list with 
echo
 as 
we would with any other variable:
echo $turtles
Next, let's look at how we set up the 
for
 loop:
for t in $turtles
Now, we're telling the interpreter to prepare to do something for every item in the 
list. The 
t
 here is arbitrary, we could've used any letter here or even a longer string. 
We're just setting up a temporary variable we want to use in order to hold the 
current item the script is working on.
do
With 
do
, we're telling the 
for
 loop to prepare itself to start doing something:
    echo $t
Now, we're printing the current value of 
$t
 to 
stdout
:
done
Just as we did with the 
while
 loop, we type 
done
 to let the interpreter know this is the 
end of the 
for
 loop. Effectively, we just created a 
for
 loop to print each item in a list 
independently:
Donatello
Leonardo
Michelangelo
Raphael
We included four turtle names in our list, and we were able to iterate through them 
and print them out, one by one.
As much as I love turtles (especially the teenage mutant ninja variety), that script 
isn't very practical or useful to us for server administration. Next, we're going to 
write a script that can actually be quite useful.


Chapter 6

Download 15,21 Mb.

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