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

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"
主站蜘蛛池模板: 邵阳市| 东宁县| 孝义市| 元江| 广德县| 巫溪县| 南开区| 通辽市| 贡觉县| 高唐县| 汶上县| 昌黎县| 福海县| 镇江市| 五原县| 洮南市| 明光市| 江都市| 锡林浩特市| 凭祥市| 明水县| 凤庆县| 淳安县| 汤原县| 南召县| 明溪县| 得荣县| 余江县| 灵台县| 万荣县| 延津县| 太白县| 新宾| 云阳县| 汝城县| 花垣县| 蒙山县| 城口县| 彭泽县| 鹤壁市| 阿拉善盟|