官术网_书友最值得收藏!

For loop

The for loop is usually used when you have multiple tasks or commands to execute for each of the entries in an array or want to execute a given command on a finite number of items. In this example, we have an array (or list) containing three elements: file1, file2, and file3. The for loop will echo each element within FILES and exit the script:

#!/bin/bash

FILES=( "file1" "file2" "file3" )
for ELEMENT in ${FILES[@]}
do
echo "${ELEMENT}"
done

echo "Echo\'d all the files"
主站蜘蛛池模板: 皮山县| 呈贡县| 大埔县| 南康市| 贵港市| 古蔺县| 永和县| 昂仁县| 铅山县| 西昌市| 锡林郭勒盟| 沁阳市| 六安市| 吴堡县| 梓潼县| 阳原县| 聂荣县| 堆龙德庆县| 易门县| 沈丘县| 科尔| 松桃| 七台河市| 云浮市| 罗平县| 武穴市| 沙河市| 邵武市| 大厂| 郁南县| 井陉县| 兴仁县| 辽阳县| 奉化市| 敦煌市| 仙游县| 福泉市| 蓬莱市| 新化县| 民权县| 陈巴尔虎旗|