- 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"
推薦閱讀
- 國際大學生程序設計競賽中山大學內部選拔真題解(二)
- Kibana Essentials
- Oracle Database 12c Security Cookbook
- 數據結構習題解析與實驗指導
- Java系統化項目開發教程
- C語言開發基礎教程(Dev-C++)(第2版)
- 詳解MATLAB圖形繪制技術
- 軟件項目管理實用教程
- Buildbox 2.x Game Development
- SEO教程:搜索引擎優化入門與進階(第3版)
- AutoCAD基礎教程
- 從零開始構建深度前饋神經網絡:Python+TensorFlow 2.x
- Mastering Object:Oriented Python(Second Edition)
- 網絡綜合布線與組網實戰指南
- Learning Redis