🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 1 (from laksa008)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
12 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.4 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.softwaretestinghelp.com/unix-shell-loops/
Last Crawled2026-04-03 03:06:28 (12 days ago)
First Indexed2018-05-16 07:06:34 (7 years ago)
HTTP Status Code200
Meta TitleUnix Shell Loop Types: Do While Loop, For Loop, Until Loop in Unix
Meta DescriptionOverview of Unix Shell Loops and different Loop Types like Unix Do While Loop, Unix For Loop, Unix Until Loop. Learn these Unix loops with examples.
Meta Canonicalnull
Boilerpipe Text
By Vijay By Vijay I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in… Updated April 1, 2025 Overview of Unix Shell Loops and Different Loop Types like: Unix Do While Loop Unix For Loop Unix Until Loop In this tutorial, we will cover the control instructions that are used to iterate a set of commands over a series of data.  Unix offers three loop structures of which we can repeat a part of a program at a specified number of times. Unix Video #17: Loops in Unix You may use different loops based on the situation. They are: #1) Unix For loop statement Example: This program will add 1+2+3+4+5 and the result will be 15 for i in 1 2 3 4 5 do sum=`expr $sum + $i` done echo $sum #2) Unix While loop statement Example: This program will print the value of ‘a’ five times, from 1 to 5. a=1 while [ $a -le 5 ] do echo “value of a=” $a a=`expr $a + 1` done #3) Unix Until loop statement This program will print the value of ‘a’ two times from 1 to 2. a=1 until [ $a -ge 3 ] do echo “value of a=” $a a=`expr $a + 1` done While running these loops, there may be a need to break out of the loop in some condition before completing all the iterations or to restart the loop before completing the remaining statements. This can be achieved with the ‘break’ and ‘continue’ statements. The following program illustrates the ‘break’ operation: num=1 while [ $num -le 5 ] do read var if [ $var -lt 0 ] then break fi num=`expr $num + 1` done echo “The loop breaks for negative numbers” Our upcoming tutorial will brief you more about working with Functions in Unix. PREV Tutorial | NEXT Tutorial Was this helpful? Thanks for your feedback! READ MORE FROM THIS SERIES: How to Install Software in Linux (3 Proper Ways) UNIX Tutorial for Beginners (20+ In-depth Unix Training Videos) Unix Commands: Basic and Advanced Unix Commands with Examples Unix File System Commands Touch, Cat, Cp, Mv, Rm, Mkdir (Part B) Unix Processes Control Commands Like Ps and Top (Part C) Unix Utilities Programs Commands: Which, Man, Find Su, Sudo (Part D) File Manipulation in Unix: Overview of Unix File System Unix File Access Permissions: Unix Chmod, Chown and Chgrp How to Compare Two Files in Unix: File Comparison Commands Unix Special Characters or Metacharacters for File Manipulation How to Use Unix Regular Expressions Unix Shell Scripting Tutorial with Examples Working with Vi Editor in Unix Working with Unix Variables: Features of Shell Scripting Unix Shell Script Arithmetic and Boolean Operators Examples Unix Conditional Statements: If Then Else and Relational Operators Using Switch Case in Unix Shell Scripting: Case-esac Statement Unix Shell Loop Types: Do While Loop, For Loop, Until Loop in Unix Unix Shell Script Functions with Parameters and Return Unix Text Processing Commands: Unix Filters with Examples Unix Pipes Tutorial: Pipes in Unix Programming More Unix Filter and Awk, Sed Commands in Text Processing Command Line Arguments in Unix Shell Script with Example Processes in Unix: Process Control and Debugging Commands Advanced Unix Shell Scripting: Arrays, File and String Test Operators, Special V… What is Unix: A Brief Introduction to Unix Unix Vs Linux: What is Difference Between UNIX and Linux Unix Permissions: File Permissions in Unix with Examples Grep Command in Unix with Simple Examples Cut Command in Unix with Examples Tar Command in Unix To Create Backups (Examples) Find Command in Unix: Find Files with Unix Find File (Examples) Ls Command in Unix with Examples Unix Cat Command Syntax, Options with Examples Unix Sort Command with Syntax, Options and Examples Linux vs Windows Difference: Which Is The Best Operating System? Linux Commands Tutorial: Learn Basic Linux Commands For Beginners 12 SCP Command Examples To Securely Transfer Files In Linux Ubuntu Vs Windows 10 – Which Is A Better OS
Markdown
[Skip to content](https://www.softwaretestinghelp.com/unix-shell-loops/#content "Skip to content") [Software Testing Help](https://www.softwaretestinghelp.com/) Menu MENUMENU - [Home](https://www.softwaretestinghelp.com/ "Software Testing Home") - [Resources](https://www.softwaretestinghelp.com/resources/ "Testing RESOURCES") - [FREE eBooks](https://www.softwaretestinghelp.com/practical-software-testing-new-free-ebook-download/ "FREE eBooks") - [QA Testing](https://www.softwaretestinghelp.com/manual-testing-tutorial-1/) - - - [Free QA Training](https://www.softwaretestinghelp.com/free-online-software-testing-qa-training-course/) - [Test Cases](https://www.softwaretestinghelp.com/how-to-write-effective-test-cases-test-cases-procedures-and-definitions/) - [SDLC](https://www.softwaretestinghelp.com/software-development-life-cycle-sdlc/) - [TestLink](https://www.softwaretestinghelp.com/testlink-tutorial-1/) - - [Software Testing](https://www.softwaretestinghelp.com/manual-testing-tutorial-1/) - [BugZilla](https://www.softwaretestinghelp.com/bugzilla-new-version-bugzilla-30-released/) - [Mobile Testing](https://www.softwaretestinghelp.com/beginners-guide-to-mobile-application-testing/) - [JIRA](https://www.softwaretestinghelp.com/atlassian-jira-tutorial-1/) - - [Agile Methodology](https://www.softwaretestinghelp.com/agile-scrum-methodology-for-development-and-testing/) - [Database Testing](https://www.softwaretestinghelp.com/database-testing-process/) - [ETL Testing](https://www.softwaretestinghelp.com/etl-testing-data-warehouse-testing/) - - [Quality Assurance](https://www.softwaretestinghelp.com/software-quality-assurance/) - [Test Management](https://www.softwaretestinghelp.com/15-best-test-management-tools-for-software-testers/) - [SAP ERP Testing](https://www.softwaretestinghelp.com/guide-erp-testing-sap-testing-1/) - [Automation](https://www.softwaretestinghelp.com/automation-testing-tutorial-1/) - - - [Automation Testing](https://www.softwaretestinghelp.com/automation-testing-tutorial-1/) - [SoapUI](https://www.softwaretestinghelp.com/web-services-api-testing-tool-soapui-tutorial-1/) - [JIRA](https://www.softwaretestinghelp.com/atlassian-jira-tutorial-1/) - [Appium](https://www.softwaretestinghelp.com/appium-studio-tutorial/) - [Karate Framework](https://www.softwaretestinghelp.com/api-testing-with-karate-framework/) - - [Selenium](https://www.softwaretestinghelp.com/selenium-tutorial-1/) - [QTP/UFT](https://www.softwaretestinghelp.com/qtp-quicktest-professional-tutorial-1/) - [ALM QC](https://www.softwaretestinghelp.com/learn-hp-quality-center-qc-in-4-days/) - [Postman](https://www.softwaretestinghelp.com/api-testing-using-postman/) - - [JMeter](https://www.softwaretestinghelp.com/jmeter-tutorials/) - [LoadRunner](https://www.softwaretestinghelp.com/hp-loadrunner-load-testing-tool-training-tutorials/) - [API Testing](https://www.softwaretestinghelp.com/api-testing-tutorial/) - [Robot Framework](https://www.softwaretestinghelp.com/robot-framework-tutorial/) - - [TestNG](https://www.softwaretestinghelp.com/testng-tutorial/) - [JUnit](https://www.softwaretestinghelp.com/junit-tutorial/) - [Eclipse](https://www.softwaretestinghelp.com/eclipse/) - [Maven](https://www.softwaretestinghelp.com/maven-tutorial/) - [Types Of Testing](https://www.softwaretestinghelp.com/types-of-software-testing/) - - - [All Testing Types](https://www.softwaretestinghelp.com/types-of-software-testing/) - [Regression Testing](https://www.softwaretestinghelp.com/regression-testing-tools-and-methods/) - [Unit Testing](https://www.softwaretestinghelp.com/unit-testing/) - [Smoke Testing](https://www.softwaretestinghelp.com/smoke-testing-and-sanity-testing-difference/) - - [Functional Testing](https://www.softwaretestinghelp.com/guide-to-functional-testing/) - [Integration Testing](https://www.softwaretestinghelp.com/what-is-integration-testing/) - [System Testing](https://www.softwaretestinghelp.com/system-testing/) - [Usability Testing](https://www.softwaretestinghelp.com/usability-testing-guide/) - - [UAT Testing](https://www.softwaretestinghelp.com/what-is-user-acceptance-testing-uat/) - [Beta Testing](https://www.softwaretestinghelp.com/beta-testing/) - [Black Box Testing](https://www.softwaretestinghelp.com/black-box-testing/) - [White Box testing](https://www.softwaretestinghelp.com/white-box-testing-techniques-with-example/) - - [Load Testing](https://www.softwaretestinghelp.com/load-testing/) - [Stress Testing](https://www.softwaretestinghelp.com/stress-testing/) - [Security Testing](https://www.softwaretestinghelp.com/how-to-test-application-security-web-and-desktop-application-security-testing-techniques/) - [Performance Testing](https://www.softwaretestinghelp.com/introduction-to-performance-testing-loadrunner-training-tutorial-part-1/) - [Tutorials](https://www.softwaretestinghelp.com/) - - - [C++](https://www.softwaretestinghelp.com/cpp-tutorials/) - [C\#](https://www.softwaretestinghelp.com/c-sharp/) - [DevOps](https://www.softwaretestinghelp.com/devops-tutorials/) - [VBScript](https://www.softwaretestinghelp.com/vbscript-tutorial-1/) - [Team Management](https://www.softwaretestinghelp.com/manage-difficult-situations-with-team-members/) - [Computer Networking](https://www.softwaretestinghelp.com/computer-networking-basics/) - [Jest](https://www.softwaretestinghelp.com/jest-testing-tutorial/) - - [Python](https://www.softwaretestinghelp.com/python/) - [JAVA](https://www.softwaretestinghelp.com/java/) - [UNIX](https://www.softwaretestinghelp.com/unix-tutorials/) - [SVN](https://www.softwaretestinghelp.com/svn-tutorial/) - [AngularJS](https://www.softwaretestinghelp.com/angularjs-tutorial/) - [Spock](https://www.softwaretestinghelp.com/spock-and-groovy/) - [Laravel](https://www.softwaretestinghelp.com/php-laravel-tutorial-for-beginners/) - - [SpecFlow](https://www.softwaretestinghelp.com/specflow-tutorial/) - [JSON](https://www.softwaretestinghelp.com/json-tutorial/) - [Flask](https://www.softwaretestinghelp.com/python-flask-tutorial/) - [SOAtest](https://www.softwaretestinghelp.com/soatest-tutorial/) - [Mockito](https://www.softwaretestinghelp.com/mockito-tutorial/) - [Karma](https://www.softwaretestinghelp.com/karma-test-runner-tutorial/) - - [Machine Learning](https://www.softwaretestinghelp.com/machine-learning-tutorials/) - [Blockchain](https://www.softwaretestinghelp.com/blockchain-tutorial/) - [GitHub](https://www.softwaretestinghelp.com/github-tutorial/) - [Gatling](https://www.softwaretestinghelp.com/gatling-tutorial/) - [Data Tools](https://www.softwaretestinghelp.com/) - - - [Oracle](https://www.softwaretestinghelp.com/oracle-products-and-services/) - [PL/SQL](https://www.softwaretestinghelp.com/pl-sql-tutorial/) - - [Data Warehouse](https://www.softwaretestinghelp.com/data-warehousing-fundamentals/) - [Excel VBA](https://www.softwaretestinghelp.com/excel-vba-tutorial/) - - [Big Data](https://www.softwaretestinghelp.com/big-data-tutorial/) - [JDBC](https://www.softwaretestinghelp.com/jdbc-tutorial/) - - [MongoDB](https://www.softwaretestinghelp.com/mongodb/) - - [Data Generation Tools](https://www.softwaretestinghelp.com/test-data-generation-tools/) - - - [Data Integration Tools](https://www.softwaretestinghelp.com/tools/26-best-data-integration-tools/) - - [Data Masking Tools](https://www.softwaretestinghelp.com/data-masking-tools/) - - [Data Migration Tools](https://www.softwaretestinghelp.com/data-migration-tools/) - - [ETL Tools](https://www.softwaretestinghelp.com/best-etl-tools/) - [More Tutorials](https://www.softwaretestinghelp.com/top-tutorials-and-tools/) # Unix Shell Loop Types: Do While Loop, For Loop, Until Loop in Unix By [Vijay](https://www.softwaretestinghelp.com/author/vijay/) By Vijay ![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20150%20150'%3E%3C/svg%3E) ![](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2018/12/Vijay-STH-blog-150x150.jpg) I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in… [Full Bio \>](https://www.softwaretestinghelp.com/author/vijay/) Follow [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20512%20512'%3E%3C/svg%3E)![](https://www.softwaretestinghelp.com/wp-content/themes/generatepress-child/img/facebook.png)](https://www.facebook.com/SoftwareTestingHelp/) [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20512%20512'%3E%3C/svg%3E)![](https://www.softwaretestinghelp.com/wp-content/themes/generatepress-child/img/linkedin.png)](https://www.linkedin.com/in/shindevijaykr/) [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20512%20512'%3E%3C/svg%3E)![](https://www.softwaretestinghelp.com/wp-content/themes/generatepress-child/img/twitter.png)](https://twitter.com/vijayshinde) *** Learn about our [editorial policies](https://www.softwaretestinghelp.com/editorial-policy-review-process/). Updated April 1, 2025 **Overview of Unix Shell Loops and Different Loop Types like:** - Unix Do While Loop - Unix For Loop - Unix Until Loop In this tutorial, we will cover the control instructions that are used to iterate a set of commands over a series of data. [![Unix Shell Loops](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2019/10/Unix-Shell-Loops.png)](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2019/10/Unix-Shell-Loops.png) Unix offers three loop structures of which we can repeat a part of a program at a specified number of times. **Unix Video \#17:** ### Loops in Unix **You may use different loops based on the situation.** **They are:** **\#1) Unix For loop statement** **Example:** This program will add 1+2+3+4+5 and the result will be 15 ``` for i in 1 2 3 4 5 do sum=`expr $sum + $i` done echo $sum ``` **\#2) Unix While loop statement** **Example:** This program will print the value of ‘a’ five times, from 1 to 5. ``` a=1 while [ $a -le 5 ] do echo “value of a=” $a a=`expr $a + 1` done ``` **\#3) Unix Until loop statement** This program will print the value of ‘a’ two times from 1 to 2. ``` a=1 until [ $a -ge 3 ] do echo “value of a=” $a a=`expr $a + 1` done ``` While running these loops, there may be a need to break out of the loop in some condition before completing all the iterations or to restart the loop before completing the remaining statements. This can be achieved with the ‘break’ and ‘continue’ statements. **The following program illustrates the ‘break’ operation:** ``` num=1 while [ $num -le 5 ] do read var if [ $var -lt 0 ] then break fi num=`expr $num + 1` done echo “The loop breaks for negative numbers” ``` ***Our upcoming tutorial will brief you more about working with Functions in Unix.*** **[PREV Tutorial](https://www.softwaretestinghelp.com/unix-switch-case/) \| [NEXT Tutorial](https://www.softwaretestinghelp.com/unix-functions/)** ### Was this helpful? Submit Cancel Thanks for your feedback\! ### Recommended Reading - [Unix Pipes Tutorial: Pipes in Unix Programming](https://www.softwaretestinghelp.com/unix-pipes/) [![Pipes in Unix Programming](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20240%20135'%3E%3C/svg%3E)![Pipes in Unix Programming](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2019/10/Pipes-in-Unix-Programming-1.png)](https://www.softwaretestinghelp.com/unix-pipes/) Overview of Pipes in Unix Programming: In this tutorial, we will learn more about Unix Pipes. Later, we will work with some of the remaining filter commands and see an example of piping them together. Unix Video \#20: Pipes in Unix A series of filter commands can be piped together… - [Java For Loop Tutorial With Program Examples](https://www.softwaretestinghelp.com/java-for-loop-tutorial/) [![Java for-loop](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20240%20135'%3E%3C/svg%3E)![Java for-loop](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2020/10/Java-for-loop-1.png)](https://www.softwaretestinghelp.com/java-for-loop-tutorial/) This tutorial will explain the concept of Java For Loop along with its syntax, description, flowchart, and programming examples: In this tutorial, we will discuss the “for-loop” in Java. We will explore each and every aspect of the looping concept along with the way of using it. This tutorial will… - [Unix Text Processing Commands: Unix Filters with Examples](https://www.softwaretestinghelp.com/unix-text-processing-commands/) [![Unix Text Processing Commands](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20240%20135'%3E%3C/svg%3E)![Unix Text Processing Commands](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2019/10/Unix-Text-Processing-Commands.png)](https://www.softwaretestinghelp.com/unix-text-processing-commands/) Overview of Unix Filters Text Processing Utilities: In this tutorial, we will learn about filters and work with various filter commands. Filters are commands that read input from stdin and write output to stdout. By default, when using a shell terminal, the stdin is from the keyboard, and the stdout is… - [What is Unix: A Brief Introduction to Unix](https://www.softwaretestinghelp.com/unix-introduction/) [![\_Introduction to Unix (1)](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20240%20135'%3E%3C/svg%3E)![\_Introduction to Unix (1)](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2022/05/Introduction-to-Unix-1.png)](https://www.softwaretestinghelp.com/unix-introduction/) Introduction to Unix Operating System: Let's start with Tutorial \#1: 'What is Unix' in this series. In this tutorial, you will be able to understand the basic concepts of operating systems, the features of Unix, along its Architecture. =\> Click here for the Complete Unix Tutorial series Unix Video \#1:… *** **READ MORE FROM THIS SERIES:** - [How to Install Software in Linux (3 Proper Ways)](https://www.softwaretestinghelp.com/3-major-ways-how-to-install-new-software-on-linux/) - [UNIX Tutorial for Beginners (20+ In-depth Unix Training Videos)](https://www.softwaretestinghelp.com/unix-tutorials/) - [Unix Commands: Basic and Advanced Unix Commands with Examples](https://www.softwaretestinghelp.com/unix-commands/) - [Unix File System Commands Touch, Cat, Cp, Mv, Rm, Mkdir (Part B)](https://www.softwaretestinghelp.com/unix-file-system-commands/) - [Unix Processes Control Commands Like Ps and Top (Part C)](https://www.softwaretestinghelp.com/unix-processes-control-command/) - [Unix Utilities Programs Commands: Which, Man, Find Su, Sudo (Part D)](https://www.softwaretestinghelp.com/unix-utilities-programs-commands/) - [File Manipulation in Unix: Overview of Unix File System](https://www.softwaretestinghelp.com/file-manipulation-unix/) - [Unix File Access Permissions: Unix Chmod, Chown and Chgrp](https://www.softwaretestinghelp.com/unix-file-access-permissions/) - [How to Compare Two Files in Unix: File Comparison Commands](https://www.softwaretestinghelp.com/compare-two-files-unix/) - [Unix Special Characters or Metacharacters for File Manipulation](https://www.softwaretestinghelp.com/unix-metacharacters/) - [How to Use Unix Regular Expressions](https://www.softwaretestinghelp.com/unix-regular-expressions/) - [Unix Shell Scripting Tutorial with Examples](https://www.softwaretestinghelp.com/unix-shell-scripting-tutorial/) - [Working with Vi Editor in Unix](https://www.softwaretestinghelp.com/unix-vi-editor/) - [Working with Unix Variables: Features of Shell Scripting](https://www.softwaretestinghelp.com/unix-variables/) - [Unix Shell Script Arithmetic and Boolean Operators Examples](https://www.softwaretestinghelp.com/unix-arithmetic-boolean-operators/) - [Unix Conditional Statements: If Then Else and Relational Operators](https://www.softwaretestinghelp.com/unix-conditional-statements/) - [Using Switch Case in Unix Shell Scripting: Case-esac Statement](https://www.softwaretestinghelp.com/unix-switch-case/) - [Unix Shell Loop Types: Do While Loop, For Loop, Until Loop in Unix](https://www.softwaretestinghelp.com/unix-shell-loops/) - [Unix Shell Script Functions with Parameters and Return](https://www.softwaretestinghelp.com/unix-functions/) - [Unix Text Processing Commands: Unix Filters with Examples](https://www.softwaretestinghelp.com/unix-text-processing-commands/) - [Unix Pipes Tutorial: Pipes in Unix Programming](https://www.softwaretestinghelp.com/unix-pipes/) - [More Unix Filter and Awk, Sed Commands in Text Processing](https://www.softwaretestinghelp.com/unix-filter-awk-sed-commands/) - [Command Line Arguments in Unix Shell Script with Example](https://www.softwaretestinghelp.com/unix-command-line-arguments/) - [Processes in Unix: Process Control and Debugging Commands](https://www.softwaretestinghelp.com/unix-processes/) - [Advanced Unix Shell Scripting: Arrays, File and String Test Operators, Special V…](https://www.softwaretestinghelp.com/advanced-shell-scripting/) - [What is Unix: A Brief Introduction to Unix](https://www.softwaretestinghelp.com/unix-introduction/) - [Unix Vs Linux: What is Difference Between UNIX and Linux](https://www.softwaretestinghelp.com/unix-vs-linux/) - [Unix Permissions: File Permissions in Unix with Examples](https://www.softwaretestinghelp.com/unix-permissions/) - [Grep Command in Unix with Simple Examples](https://www.softwaretestinghelp.com/grep-command-in-unix/) - [Cut Command in Unix with Examples](https://www.softwaretestinghelp.com/cut-command-in-unix/) - [Tar Command in Unix To Create Backups (Examples)](https://www.softwaretestinghelp.com/tar-command-in-unix/) - [Find Command in Unix: Find Files with Unix Find File (Examples)](https://www.softwaretestinghelp.com/find-command-in-unix/) - [Ls Command in Unix with Examples](https://www.softwaretestinghelp.com/ls-command-in-unix/) - [Unix Cat Command Syntax, Options with Examples](https://www.softwaretestinghelp.com/unix-cat-command/) - [Unix Sort Command with Syntax, Options and Examples](https://www.softwaretestinghelp.com/unix-sort-command/) - [Linux vs Windows Difference: Which Is The Best Operating System?](https://www.softwaretestinghelp.com/linux-vs-windows/) - [Linux Commands Tutorial: Learn Basic Linux Commands For Beginners](https://www.softwaretestinghelp.com/linux-commands-tutorial/) - [12 SCP Command Examples To Securely Transfer Files In Linux](https://www.softwaretestinghelp.com/scp-command-tutorial/) - [Ubuntu Vs Windows 10 – Which Is A Better OS](https://www.softwaretestinghelp.com/ubuntu-vs-windows/) *** ### Leave a Comment [Cancel reply](https://www.softwaretestinghelp.com/unix-shell-loops/#respond) ## About SoftwareTestingHelp **Helping our community since 2006\!** Most popular portal for Software professionals with **400 million+ visits and 500,000+ followers\!** You will absolutely love our creative content on QA, Dev, Software Tools & Services Reviews\! [![](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2020/11/sth-author-jobs.png)](https://www.softwaretestinghelp.com/become-an-author/) [Software Testing Help](https://www.softwaretestinghelp.com/) **Communication Details** **Main Office:** A708, City Vista, Fountain Road, Kharadi, Pune, MH, 411014. **Email Us:** info@softwaretestinghelp.com [Facebook](https://www.facebook.com/SoftwareTestingHelp/) [Linkedin](https://www.linkedin.com/in/shindevijaykr/) [X-twitter](https://x.com/vijayshinde?lang=en) [Youtube](https://www.youtube.com/user/shindevijaykr) Software Testing Tools - [Test Management Tools](https://www.softwaretestinghelp.com/best-test-management-tools/) - [Web Application Testing Software](https://www.softwaretestinghelp.com/most-popular-web-application-testing-tools/) - [Cross Browser Testing Tools](https://www.softwaretestinghelp.com/best-cross-browser-testing-tools-to-ease-your-browser-compatibility-testing-efforts/) - [Best ETL Testing Tools](https://www.softwaretestinghelp.com/top-4-etl-testing-tools/) - [Mobile Testing Tools](https://www.softwaretestinghelp.com/best-mobile-testing-tools/) - [Regression Testing Tools](https://www.softwaretestinghelp.com/regression-testing-tools/) - [Defect Tracking Tools](https://www.softwaretestinghelp.com/popular-bug-tracking-software/) - [GUI Testing Tools](https://www.softwaretestinghelp.com/best-gui-testing-tools/) - [Requirements Management Tools](https://www.softwaretestinghelp.com/requirements-management-tools/) - [ALL Testing Tools](https://www.softwaretestinghelp.com/top-software-categories/#Software_Testing_Tools) Performance Testing Tools - [Performance Testing Tools](https://www.softwaretestinghelp.com/performance-testing-tools-load-testing-tools/) - [Performance Testing Services](https://www.softwaretestinghelp.com/performance-testing-service-providers/) - [Computer Stress Test Tools](https://www.softwaretestinghelp.com/computer-stress-test-software/) - [Cloud- Load Testing Service](https://www.softwaretestinghelp.com/cloud-performance-testing/) - [Performance Testing Guide](https://www.softwaretestinghelp.com/introduction-to-performance-testing-loadrunner-training-tutorial-part-1/) - [Database Performance Tools](https://www.softwaretestinghelp.com/database-performance-analyzer/) - [Website Performance Testing Tools](https://www.softwaretestinghelp.com/website-performance-test/) - [Application Performance Monitoring](https://www.softwaretestinghelp.com/top-10-application-performance-monitoring-tools/) Automation Testing Tools - [Unit Testing Tools](https://www.softwaretestinghelp.com/unit-testing-tools/) - [API Testing Tools](https://www.softwaretestinghelp.com/api-testing-tools/) - [Best ETL Tools](https://www.softwaretestinghelp.com/best-etl-tools/) - [Open Source Testing Tools](https://www.softwaretestinghelp.com/open-source-testing-tools/) - [Functional Testing Tools](https://www.softwaretestinghelp.com/tools/top-30-functional-testing-tools/) - [Selenium Alternatives](https://www.softwaretestinghelp.com/selenium-alternatives/) - [Accessibility Testing Tools](https://www.softwaretestinghelp.com/accessibility-testing-tools/) - [Mobile Automation Tools](https://www.softwaretestinghelp.com/5-best-automation-tools-for-testing-android-applications/) - [Automation Testing Software](https://www.softwaretestinghelp.com/top-20-automation-testing-tools/) - [Automation Testing Services](https://www.softwaretestinghelp.com/automation-testing-service-providers/) Data Tools - [Data Masking Tools](https://www.softwaretestinghelp.com/data-masking-tools/) - [Data Modeling Tools](https://www.softwaretestinghelp.com/data-modeling-tools/) - [Data Analysis Tools](https://www.softwaretestinghelp.com/data-analysis-tools/) - [Data Migration Software](https://www.softwaretestinghelp.com/data-migration-tools/) - [Data Integration Tools](https://www.softwaretestinghelp.com/tools/26-best-data-integration-tools/) - [Data Mapping Tools](https://www.softwaretestinghelp.com/data-mapping-tools/) - [Data Loss Prevention](https://www.softwaretestinghelp.com/data-loss-prevention-software/) - [Test Data Management Tools](https://www.softwaretestinghelp.com/tools/14-test-data-management-tools/) - [Data Recovery Software](https://www.softwaretestinghelp.com/best-data-recovery-software/) - [Data Analytics Companies](https://www.softwaretestinghelp.com/data-analytics-companies/) - [ALL Data Tools](https://www.softwaretestinghelp.com/top-software-categories/#Data_Software) Coding Software - [Best Code Editors](https://www.softwaretestinghelp.com/best-code-editor/) - [Code Coverage Tools](https://www.softwaretestinghelp.com/code-coverage-tools/) - [Low-Code Development Tools](https://www.softwaretestinghelp.com/low-code-development-platforms/) - [Static Code Analysis Tools](https://www.softwaretestinghelp.com/tools/top-40-static-code-analysis-tools/) - [Source Code Management Tools](https://www.softwaretestinghelp.com/best-source-code-management-tools/) - [Version Control Software](https://www.softwaretestinghelp.com/version-control-software/) - [Code Review Tools](https://www.softwaretestinghelp.com/code-review-tools/) - [Javascript Online Editors](https://www.softwaretestinghelp.com/javascript-ide-and-online-code-editors/) - [Code Review Tools](https://www.softwaretestinghelp.com/code-review-tools/) - [Code Quality Tools](https://www.softwaretestinghelp.com/code-quality-tools/) Security Testing Tools - [Penetration Testing Tools](https://www.softwaretestinghelp.com/penetration-testing-tools/) - [App Security Testing Tools](https://www.softwaretestinghelp.com/application-security-testing-software/) - [Web Security Scanners](https://www.softwaretestinghelp.com/web-security-scanners/) - [Vulnerability Assessment](https://www.softwaretestinghelp.com/vulnerability-assessment-tools/) - [Mobile App Security](https://www.softwaretestinghelp.com/mobile-app-security-testing-tools/) - [Malware Removal Tools](https://www.softwaretestinghelp.com/best-malware-removal/) - [Anti-Ransomware Tools](https://www.softwaretestinghelp.com/anti-ransomware-software/) - [Spyware Removal Tools](https://www.softwaretestinghelp.com/spyware-removal-tools/) - [Mobile Pen Testing Tools](https://www.softwaretestinghelp.com/mobile-app-pen-testing-tools-service-providers/) - [Pen Testing as a Service](https://www.softwaretestinghelp.com/top-pen-testing-as-a-service-providers/) - [DAST Software](https://www.softwaretestinghelp.com/dynamic-application-security-testing-dast-software/) Testing Service Providers - [Managed Testing Services](https://www.softwaretestinghelp.com/managed-testing-service-providers/) - [Mobile Testing Services](https://www.softwaretestinghelp.com/mobile-testing-services/) - [Software Testing Services](https://www.softwaretestinghelp.com/software-testing-service-providers/) - [Performance Testing Services](https://www.softwaretestinghelp.com/performance-testing-service-providers/) - [Penetration Testing Companies](https://www.softwaretestinghelp.com/penetration-testing-company/) - [Cyber Security Companies](https://www.softwaretestinghelp.com/best-cyber-security-companies/) - [QA Outsourcing Companies](https://www.softwaretestinghelp.com/qa-outsourcing/) - [USA Testing Companies](https://www.softwaretestinghelp.com/software-testing-companies-usa/) - [Website Testing Services](https://www.softwaretestinghelp.com/website-testing-services/) - [Regression Testing Services](https://www.softwaretestinghelp.com/regression-testing-service-providers/) Software Development - [Custom Software Companies](https://www.softwaretestinghelp.com/custom-software-development-company/) - [App Development Tools](https://www.softwaretestinghelp.com/best-app-development-software/) - [Software Development Tools](https://www.softwaretestinghelp.com/software-development-tools/) - [Game Development Companies](https://www.softwaretestinghelp.com/game-development-companies/) - [Software Companies USA](https://www.softwaretestinghelp.com/best-software-development-companies-usa/) - [SaaS Development Companies](https://www.softwaretestinghelp.com/best-saas-development-company/) - [Android App Development](https://www.softwaretestinghelp.com/android-app-development-companies/) - [DevOps Tools](https://www.softwaretestinghelp.com/devops-tools/) - [DevOps Service Providers](https://www.softwaretestinghelp.com/devops-service-provider-companies/) - [App Development Companies](https://www.softwaretestinghelp.com/mobile-application-development-companies/) - [Healthcare Dev Companies](https://www.softwaretestinghelp.com/healthcare-software-development-companies/) Networking Tools - [Network Management](https://www.softwaretestinghelp.com/network-management-software/) - [Network Security Tools](https://www.softwaretestinghelp.com/network-security-software/) - [Network Scanning Tools](https://www.softwaretestinghelp.com/network-scanning-tools/) - [Application Scanners](https://www.softwaretestinghelp.com/online-application-scanners/) - [Network Testing Tools](https://www.softwaretestinghelp.com/network-testing-tools/) - [Network Monitoring Tools](https://www.softwaretestinghelp.com/network-monitoring-tools/) - [Network Security Tools](https://www.softwaretestinghelp.com/network-security-testing-and-tools/) - [Server Monitoring Tools](https://www.softwaretestinghelp.com/top-10-popular-server-monitoring-tools/) - [Network Mapping Software](https://www.softwaretestinghelp.com/network-mapping-software/) - [SIEM Tools](https://www.softwaretestinghelp.com/siem-tools/) - [System Monitoring Tools](https://www.softwaretestinghelp.com/system-monitoring-software/) - [Infrastructure Monitoring Tools](https://www.softwaretestinghelp.com/infrastructure-monitoring-tools-and-services/) Project Management Tools - [Project Management Software](https://www.softwaretestinghelp.com/project-management-software-tools/) - [Project Management Apps](https://www.softwaretestinghelp.com/project-management-apps/) - [Agile Project Management Tools](https://www.softwaretestinghelp.com/agile-project-management-tools/) - [Workflow Management Software](https://www.softwaretestinghelp.com/workflow-management-software/) - [Task Management Software](https://www.softwaretestinghelp.com/best-task-management-software-systems/) - [Team Collaboration Tools](https://www.softwaretestinghelp.com/best-team-collaboration-tool/) - [JIRA Alternatives](https://www.softwaretestinghelp.com/jira-alternatives/) - [Project Planning Tools](https://www.softwaretestinghelp.com/project-planning-tools/) - [Team Management Software](https://www.softwaretestinghelp.com/best-team-management-software-tools/) Cloud Tools - [Cloud Monitoring Tools](https://www.softwaretestinghelp.com/cloud-monitoring-tools/) - [Crowdsourcing Platforms](https://www.softwaretestinghelp.com/best-crowdsourcing-platforms/) - [Cloud Management](https://www.softwaretestinghelp.com/cloud-management-platforms/) - [Crowdsourced Testing Companies](https://www.softwaretestinghelp.com/crowdsourced-testing-companies/) - [Cloud Mobile Testing](https://www.softwaretestinghelp.com/cloud-mobile-testing-services/) - [Cloud Computing Companies](https://www.softwaretestinghelp.com/cloud-computing-service-providers/) - [Cloud Managed Services](https://www.softwaretestinghelp.com/best-cloud-managed-services/) - [Cloud Testing Tools](https://www.softwaretestinghelp.com/cloud-testing-tools/) - [Cloud Security Companies](https://www.softwaretestinghelp.com/cloud-security-companies/) - [ALL Categories](https://www.softwaretestinghelp.com/top-software-categories/) Security Software - [Free Antivirus Software](https://www.softwaretestinghelp.com/best-free-antivirus-software/) - [Cybersecurity Software](https://www.softwaretestinghelp.com/cybersecurity-software-tools/) - [Internet Security Tools](https://www.softwaretestinghelp.com/best-internet-security-software/) - [External Vulnerability Scanner](https://www.softwaretestinghelp.com/external-vulnerability-scanner/) - [Website Malware Scanner](https://www.softwaretestinghelp.com/website-malware-scanner-tools/) - [Web Security Scanners](https://www.softwaretestinghelp.com/web-security-scanners/) - [Zero Trust Security](https://www.softwaretestinghelp.com/zero-trust-security-solutions/) - [Vulnerability Assessment](https://www.softwaretestinghelp.com/vulnerability-assessment-tools/) - [ALL Security Tools](https://www.softwaretestinghelp.com/top-software-categories/#Security_Software) IT Management Tools - [Remote Desktop Software](https://www.softwaretestinghelp.com/remote-desktop-software/) - [Configuration Management](https://www.softwaretestinghelp.com/top-5-software-configuration-management-tools/) - [Incident Management Software](https://www.softwaretestinghelp.com/incident-management-software/) - [Change Management Software](https://www.softwaretestinghelp.com/change-management-software/) - [IT Asset Management](https://www.softwaretestinghelp.com/it-asset-management-software/) - [Managed IT Services](https://www.softwaretestinghelp.com/managed-it-service-providers/) - [ITSM Tools](https://www.softwaretestinghelp.com/itsm-tools/) - [Remote Monitoring Software](https://www.softwaretestinghelp.com/best-rmm-software/) - [Remote Access Software](https://www.softwaretestinghelp.com/remote-access-software/) - [Asset Discovery Tools](https://www.softwaretestinghelp.com/asset-discovery-tools/) - [Workload Automation Tools](https://www.softwaretestinghelp.com/workload-automation-tools/) - [IT Automation Tools](https://www.softwaretestinghelp.com/best-it-automation-tools/) **[About us](https://www.softwaretestinghelp.com/about/) \| [Contact us](https://www.softwaretestinghelp.com/contact/) \| [Advertise](https://www.softwaretestinghelp.com/advertise-on-software-testing-help/)** All articles are copyrighted and cannot be reproduced without permission. SoftwareTestingHelp® is a registered trademark. ©SoftwareTestingHelp 2025 — Read our **[Copyright Policy](https://www.softwaretestinghelp.com/copyright-policy/) \| [Privacy Policy](https://www.softwaretestinghelp.com/privacy/) \| [Terms](https://www.softwaretestinghelp.com/terms-of-use/) \| [Cookie Policy](https://www.softwaretestinghelp.com/cookie-policy/) \| [Affiliate Disclaimer](https://www.softwaretestinghelp.com/affiliate-disclaimer/)** [![Software Testing Help](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20524%2039'%3E%3C/svg%3E)![Software Testing Help](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2023/03/Thanks-for-reading-STH.png)](https://www.softwaretestinghelp.com/become-an-author/)
Readable Markdown
By [Vijay](https://www.softwaretestinghelp.com/author/vijay/) By Vijay ![](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2018/12/Vijay-STH-blog-150x150.jpg) I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in… Updated April 1, 2025 **Overview of Unix Shell Loops and Different Loop Types like:** - Unix Do While Loop - Unix For Loop - Unix Until Loop In this tutorial, we will cover the control instructions that are used to iterate a set of commands over a series of data. [![Unix Shell Loops](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2019/10/Unix-Shell-Loops.png)](https://www.softwaretestinghelp.com/wp-content/qa/uploads/2019/10/Unix-Shell-Loops.png) Unix offers three loop structures of which we can repeat a part of a program at a specified number of times. **Unix Video \#17:** ### Loops in Unix **You may use different loops based on the situation.** **They are:** **\#1) Unix For loop statement** **Example:** This program will add 1+2+3+4+5 and the result will be 15 ``` for i in 1 2 3 4 5 do sum=`expr $sum + $i` done echo $sum ``` **\#2) Unix While loop statement** **Example:** This program will print the value of ‘a’ five times, from 1 to 5. ``` a=1 while [ $a -le 5 ] do echo “value of a=” $a a=`expr $a + 1` done ``` **\#3) Unix Until loop statement** This program will print the value of ‘a’ two times from 1 to 2. ``` a=1 until [ $a -ge 3 ] do echo “value of a=” $a a=`expr $a + 1` done ``` While running these loops, there may be a need to break out of the loop in some condition before completing all the iterations or to restart the loop before completing the remaining statements. This can be achieved with the ‘break’ and ‘continue’ statements. **The following program illustrates the ‘break’ operation:** ``` num=1 while [ $num -le 5 ] do read var if [ $var -lt 0 ] then break fi num=`expr $num + 1` done echo “The loop breaks for negative numbers” ``` ***Our upcoming tutorial will brief you more about working with Functions in Unix.*** **[PREV Tutorial](https://www.softwaretestinghelp.com/unix-switch-case/) \| [NEXT Tutorial](https://www.softwaretestinghelp.com/unix-functions/)** Was this helpful? Thanks for your feedback\! *** **READ MORE FROM THIS SERIES:** - [How to Install Software in Linux (3 Proper Ways)](https://www.softwaretestinghelp.com/3-major-ways-how-to-install-new-software-on-linux/) - [UNIX Tutorial for Beginners (20+ In-depth Unix Training Videos)](https://www.softwaretestinghelp.com/unix-tutorials/) - [Unix Commands: Basic and Advanced Unix Commands with Examples](https://www.softwaretestinghelp.com/unix-commands/) - [Unix File System Commands Touch, Cat, Cp, Mv, Rm, Mkdir (Part B)](https://www.softwaretestinghelp.com/unix-file-system-commands/) - [Unix Processes Control Commands Like Ps and Top (Part C)](https://www.softwaretestinghelp.com/unix-processes-control-command/) - [Unix Utilities Programs Commands: Which, Man, Find Su, Sudo (Part D)](https://www.softwaretestinghelp.com/unix-utilities-programs-commands/) - [File Manipulation in Unix: Overview of Unix File System](https://www.softwaretestinghelp.com/file-manipulation-unix/) - [Unix File Access Permissions: Unix Chmod, Chown and Chgrp](https://www.softwaretestinghelp.com/unix-file-access-permissions/) - [How to Compare Two Files in Unix: File Comparison Commands](https://www.softwaretestinghelp.com/compare-two-files-unix/) - [Unix Special Characters or Metacharacters for File Manipulation](https://www.softwaretestinghelp.com/unix-metacharacters/) - [How to Use Unix Regular Expressions](https://www.softwaretestinghelp.com/unix-regular-expressions/) - [Unix Shell Scripting Tutorial with Examples](https://www.softwaretestinghelp.com/unix-shell-scripting-tutorial/) - [Working with Vi Editor in Unix](https://www.softwaretestinghelp.com/unix-vi-editor/) - [Working with Unix Variables: Features of Shell Scripting](https://www.softwaretestinghelp.com/unix-variables/) - [Unix Shell Script Arithmetic and Boolean Operators Examples](https://www.softwaretestinghelp.com/unix-arithmetic-boolean-operators/) - [Unix Conditional Statements: If Then Else and Relational Operators](https://www.softwaretestinghelp.com/unix-conditional-statements/) - [Using Switch Case in Unix Shell Scripting: Case-esac Statement](https://www.softwaretestinghelp.com/unix-switch-case/) - [Unix Shell Loop Types: Do While Loop, For Loop, Until Loop in Unix](https://www.softwaretestinghelp.com/unix-shell-loops/) - [Unix Shell Script Functions with Parameters and Return](https://www.softwaretestinghelp.com/unix-functions/) - [Unix Text Processing Commands: Unix Filters with Examples](https://www.softwaretestinghelp.com/unix-text-processing-commands/) - [Unix Pipes Tutorial: Pipes in Unix Programming](https://www.softwaretestinghelp.com/unix-pipes/) - [More Unix Filter and Awk, Sed Commands in Text Processing](https://www.softwaretestinghelp.com/unix-filter-awk-sed-commands/) - [Command Line Arguments in Unix Shell Script with Example](https://www.softwaretestinghelp.com/unix-command-line-arguments/) - [Processes in Unix: Process Control and Debugging Commands](https://www.softwaretestinghelp.com/unix-processes/) - [Advanced Unix Shell Scripting: Arrays, File and String Test Operators, Special V…](https://www.softwaretestinghelp.com/advanced-shell-scripting/) - [What is Unix: A Brief Introduction to Unix](https://www.softwaretestinghelp.com/unix-introduction/) - [Unix Vs Linux: What is Difference Between UNIX and Linux](https://www.softwaretestinghelp.com/unix-vs-linux/) - [Unix Permissions: File Permissions in Unix with Examples](https://www.softwaretestinghelp.com/unix-permissions/) - [Grep Command in Unix with Simple Examples](https://www.softwaretestinghelp.com/grep-command-in-unix/) - [Cut Command in Unix with Examples](https://www.softwaretestinghelp.com/cut-command-in-unix/) - [Tar Command in Unix To Create Backups (Examples)](https://www.softwaretestinghelp.com/tar-command-in-unix/) - [Find Command in Unix: Find Files with Unix Find File (Examples)](https://www.softwaretestinghelp.com/find-command-in-unix/) - [Ls Command in Unix with Examples](https://www.softwaretestinghelp.com/ls-command-in-unix/) - [Unix Cat Command Syntax, Options with Examples](https://www.softwaretestinghelp.com/unix-cat-command/) - [Unix Sort Command with Syntax, Options and Examples](https://www.softwaretestinghelp.com/unix-sort-command/) - [Linux vs Windows Difference: Which Is The Best Operating System?](https://www.softwaretestinghelp.com/linux-vs-windows/) - [Linux Commands Tutorial: Learn Basic Linux Commands For Beginners](https://www.softwaretestinghelp.com/linux-commands-tutorial/) - [12 SCP Command Examples To Securely Transfer Files In Linux](https://www.softwaretestinghelp.com/scp-command-tutorial/) - [Ubuntu Vs Windows 10 – Which Is A Better OS](https://www.softwaretestinghelp.com/ubuntu-vs-windows/) ***
Shard1 (laksa)
Root Hash15064000948048152601
Unparsed URLcom,softwaretestinghelp!www,/unix-shell-loops/ s443