September 2018
Beginner
186 pages
4h 30m
English
The for keyword is used to define code to run repeatedly over a list of shell words:
#!/bin/bash
for system in bsd linux macosx windows ; do
printf '%s\n' "${system^^}"
done
The preceding code loops through the list of four items, assigning each one in turn to the system variable. The body of the loop prints the value of the system variable in all caps, for each iteration of the loop.
Note the following about the preceding syntax:
Read now
Unlock full access