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

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"
主站蜘蛛池模板: 平定县| 彰武县| 凤城市| 聂拉木县| 桐庐县| 四平市| 建德市| 麦盖提县| 新乐市| 潞城市| 勐海县| 郁南县| 依安县| 泽普县| 宝丰县| 青田县| 东安县| 麻江县| 固镇县| 梅州市| 门源| 阿拉尔市| 桂东县| 安顺市| 沅陵县| 闽侯县| 柘荣县| 疏勒县| 崇仁县| 沛县| 通辽市| 南和县| 汉中市| 库尔勒市| 石阡县| 密山市| 阿城市| 福海县| 油尖旺区| 沂水县| 六枝特区|