- 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"
推薦閱讀
- C++面向對象程序設計(第三版)
- Leap Motion Development Essentials
- SQL for Data Analytics
- ASP.NET動態網頁設計教程(第三版)
- Python金融數據分析
- Java程序設計與實踐教程(第2版)
- CouchDB and PHP Web Development Beginner’s Guide
- C語言程序設計同步訓練與上機指導(第三版)
- 青少年學Python(第1冊)
- The DevOps 2.5 Toolkit
- Working with Odoo
- Frank Kane's Taming Big Data with Apache Spark and Python
- OpenMP核心技術指南
- Natural Language Processing with Python Quick Start Guide
- C/C++代碼調試的藝術(第2版)