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

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"
主站蜘蛛池模板: 株洲市| 汶上县| 英超| 威海市| 专栏| 松溪县| 财经| 新民市| 汨罗市| 霍林郭勒市| 于田县| 平阴县| 宁安市| 远安县| 隆林| 禹城市| 石阡县| 宣武区| 绥化市| 巴彦县| 平顶山市| 西安市| 岳阳县| 浦城县| 南昌市| 故城县| 贵德县| 扶风县| 宜川县| 库尔勒市| 青铜峡市| 开远市| 潞西市| 仁化县| 扬州市| 商都县| 高碑店市| 宝坻区| 香格里拉县| 东乡| 福贡县|