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

  • Bash Cookbook
  • Ron Brash Ganesh Naik
  • 86字
  • 2021-07-23 19:17:30

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"
主站蜘蛛池模板: 滕州市| 盘锦市| 寻乌县| 海林市| 濮阳市| 霍林郭勒市| 蒙山县| 济南市| 石阡县| 巴林右旗| 翁牛特旗| 内黄县| 洛浦县| 汝南县| 宜州市| 利津县| 桑植县| 山丹县| 金寨县| 兴文县| 兴山县| 南部县| 海安县| 弥勒县| 通渭县| 依兰县| 商都县| 岳阳县| 财经| 大化| 泾源县| 仪陇县| 屯留县| 团风县| 武陟县| 卢氏县| 徐水县| 威海市| 阳高县| 长白| 丹东市|