- 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"
推薦閱讀
- Maven Build Customization
- PHP 從入門到項目實踐(超值版)
- PHP基礎案例教程
- OpenStack Cloud Computing Cookbook(Fourth Edition)
- Linux命令行與shell腳本編程大全(第4版)
- Rust Essentials(Second Edition)
- Unity 5 for Android Essentials
- 領域驅動設計:軟件核心復雜性應對之道(修訂版)
- App Inventor少兒趣味編程動手做
- Elasticsearch Blueprints
- FusionCharts Beginner’s Guide:The Official Guide for FusionCharts Suite
- 小學生C++趣味編程從入門到精通
- Python機器學習
- JavaScript高級程序設計(第4版)
- Mastering R for Quantitative Finance