Skip to content
Note Arena
  • Java
  • Python Programming
  • Linux
  • Git Course
  • Log4j
  • Tutorials
    • Java
    • Python Programming
    • Git
    • Log4j
    • IELTS Basics
    • MySQL
    • How to?
    • Linux
  • COVID-19 (Coronavirus)
    • COVID-19 (Coronavirus) Updates
    • Corona Virus Map
    • Corona Virus (Asia)
    • Corona Virus update for Bangladesh
  • Converters
    • Currency Converter
    • Unit Converters
  • Use Apps
  • Search
  • Installation
    • Downloads and Installations
    • Installing VMWare Workstation Player/ Pro in Linux (Ubuntu)
    • Uninstalling VMWare Workstation Player/ Pro from Linux (Ubuntu)
    • Install CentOS in VirtualBox
  • Using Linux (Setup and Commands)
    • Get Started with Linux and some initial setups
    • How to Create File in Linux
    • Find or Search Files in Linux from the Command Line
  • Shell Scripting
    • Shell Variable Basic
    • Shell Script Comments
    • Shell Script Conditional Statements (if .. elif ..else )
    • Linux Shell Script Conditional Statements-case…esac
    • Linux Shell Script Loops
    • Function in Linux Shell Scripting
    • Shell Scripting Loop: While
    • File Manipulation in Linux Shell Scripting
    • How to Access Database(MySQL/MariaDB) in Linux Shell Scripting
    • How to Read a Properties File in Linux Shell Scripting

Shell Scripting Loop: While

Back to: Linux

While Loop

Syntax for while loop:

           while [ condition ]
           do
                 statement1
                 statement2
           done

While loop example:

#!/usr/bin/env bash            
                
# While loop example                       
COUNTER=0       
                
while [ $COUNTER -le 5 ]                      
do                      
 echo "COUNT = $COUNTER"       
                
 ((COUNTER++))       
                
done       
                               
echo "while loop completed."       

Output:

COUNT = 0
COUNT = 1
COUNT = 2
COUNT = 3
COUNT = 4
COUNT = 5
while loop completed.

Follow us on social media

YouTube
Facebook

About Us

This blog is intended to provide quality content on modern technologies for software development.  We write content based on our real development experiences.

 

Important Links

  • Home
  • About US
  • Contact
  • Feedback and Suggestions

Useful Links

  • Projects
  • Java Learning
  • Python Learning
  • Linux and Scripting

Get In Touch

  • Ottawa, Canada
  • note.arena10@gmail.com
Copyright © 2022 Note Arena | All Right Reserved | Powered by Note Arena