User Tools

Site Tools


bash:while_loop

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bash:while_loop [2019/12/12 20:17] – created peterbash:while_loop [2021/01/26 12:08] (current) – removed peter
Line 1: Line 1:
-====== BASH - While loo ====== 
- 
-The while loop construct is used for running some instruction multiple times. 
- 
-<code bash> 
-#!/bin/bash 
-i=0 
- 
-while [ $i -le 2 ] 
-do 
-echo Number: $i 
-((i++)) 
-done 
-</code> 
- 
-So, the while loop takes the below form. 
- 
-<code bash> 
-while [ condition ] 
-do 
-commands 1 
-commands n 
-done 
-</code> 
- 
-<WRAP info> 
-**NOTE:**  The space surrounding the square brackets are mandatory. 
-</WRAP> 
- 
  
bash/while_loop.1576181832.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki