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

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"
主站蜘蛛池模板: 务川| 全州县| 子洲县| 都兰县| 新营市| 大足县| 莒南县| 斗六市| 虞城县| 油尖旺区| 大田县| 桃园县| 双辽市| 通江县| 定南县| 陕西省| 修水县| 佛山市| 丹棱县| 东阳市| 阳新县| 新源县| 格尔木市| 孙吴县| 甘泉县| 岐山县| 中西区| 襄汾县| 大田县| 万安县| 沅陵县| 江永县| 虞城县| 鹤壁市| 凤城市| 武义县| 乌拉特前旗| 平利县| 广安市| 吉木乃县| 仁怀市|