Sunday, 22 Mar 2026
Subscribe
logo
  • Global
  • AI
  • Cloud Computing
  • Edge Computing
  • Security
  • Investment
  • Sustainability
  • More
    • Colocation
    • Quantum Computing
    • Regulation & Policy
    • Infrastructure
    • Power & Cooling
    • Design
    • Innovations
    • Blog
Font ResizerAa
Data Center NewsData Center News
Search
  • Global
  • AI
  • Cloud Computing
  • Edge Computing
  • Security
  • Investment
  • Sustainability
  • More
    • Colocation
    • Quantum Computing
    • Regulation & Policy
    • Infrastructure
    • Power & Cooling
    • Design
    • Innovations
    • Blog
Have an existing account? Sign In
Follow US
© 2022 Foxiz News Network. Ruby Design Company. All Rights Reserved.
Data Center News > Blog > Global Market > How to loop forever in bash
Global Market

How to loop forever in bash

Last updated: November 11, 2024 9:58 am
Published November 11, 2024
Share
upside down roller coaster in a loop against a cloud and blue sky amusement park
SHARE

Contents
Utilizing forWhy loop without end?
whereas :
do
echo Maintain working
echo "Press CTRL+C to exit"
sleep 3
finished

You are able to do the identical factor in a single line by separating the strains proven above with semicolons as proven within the instance under.

whereas true; do echo Maintain working; echo 'Press CTRL+C'; sleep 3; finished

The command under would work the identical. I want whereas true as a result of it appears apparent, however any of the examples proven will work as does this one:

whereas [ 1 ]
do
echo Maintain working
echo "Press CTRL+C to exit"
sleep 3
finished

Utilizing for

The for command additionally gives a simple method to loop without end. Whereas not fairly as apparent as the whereas true choice, the syntax within reason simple. You possibly can simply substitute the parameters in a traditional for loop (the beginning, situation and increment values) that will usually look one thing like this:

$ for (int i = 0; i < 5; i++)

As a substitute, use the for command with no such values as within the instance under.

$ for (( ; ; ))
> do
> echo Maintain your spirits up
> echo “Press CTRL+C to exit”
> sleep 3
> finished
Maintain your spirits up
“Press CTRL+C to exit“
Maintain your spirits up
“Press CTRL+C to exit“
Maintain your spirits up
“Press CTRL+C to exit“

And, clearly, press CTRL-C if you need to exit the loop.

Why loop without end?

In fact, you’re not ever going to need to loop without end, however having loops run till you cease them can usually be very helpful. The script under runs till 5:00 p.m. It makes use of the date command with the +%H choice to verify the time, then reminds you that it’s time to go residence and exits. The sleep 60 command was included to restrict the time checking to as soon as a minute. In any other case, this script may gobble up lots of CPU time.

See also  The VB AI Impact Tour: How long will humans stay in the auditing loop?

Source link

TAGGED: bash, loop
Share This Article
Twitter Email Copy Link Print
Previous Article Cogna Raises $15M in Series A Funding Cogna Raises $15M in Series A Funding
Next Article New Planning Guidelines Set to Drive Growth New Planning Guidelines Set to Drive Growth
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Your Trusted Source for Accurate and Timely Updates!

Our commitment to accuracy, impartiality, and delivering breaking news as it happens has earned us the trust of a vast audience. Stay ahead with real-time updates on the latest events, trends.
FacebookLike
TwitterFollow
InstagramFollow
YoutubeSubscribe
LinkedInFollow
MediumFollow
- Advertisement -
Ad image

Popular Posts

Sam Altman admits OpenAI was ‘on the wrong side of history’ in open source debate

Be a part of our every day and weekly newsletters for the most recent updates…

February 1, 2025

Azure Data Factory Bugs Expose Cloud Infrastructure

Three flaws found in the best way Microsoft's Azure-based information integration service leverages an open supply workflow…

December 18, 2024

The Verge is not interested in interviewing you about crypto — but scammers are

If you get a message from someone at The Verge asking to schedule an interview…

January 29, 2024

Amazon Calls for Global Alignment on Responsible AI Policies

Amazon is asking for pressing world alignment on accountable AI insurance policies, arguing that collaboration between…

July 31, 2024

GlobalSign CA platform automates certificate management

Certificates Authority GMO GlobalSign has debuted LifeCycleX, its fifth certificates lifecycle administration (CLM) resolution, designed…

September 19, 2025

You Might Also Like

Cloud Security Concept: Businessman uses tablet on Secure Global Networking, Data Encryption, Firewall Protection, Continuous Monitoring, to Develop Smart Solutions from Digital Technology.
Global Market

Versa extends SASE platform with Inbound SSE and Secure Enterprise Browser

By saad
Nvidia space data center
Global Market

Nvidia joins push for data centers in space

By saad
The European Commission headquarters in Brussels (8)
Global Market

Beware hyperscalers’ ‘sovereignty washing,’ Euro cloud operators tell EU

By saad
Schneider Electric, NVIDIA and AVEVA unveil AI data centre design tools
Global Market

Schneider Electric, NVIDIA and AVEVA unveil AI data centre design tools

By saad
Data Center News
Facebook Twitter Youtube Instagram Linkedin

About US

Data Center News: Stay informed on the pulse of data centers. Latest updates, tech trends, and industry insights—all in one place. Elevate your data infrastructure knowledge.

Top Categories
  • Global Market
  • Infrastructure
  • Innovations
  • Investments
Usefull Links
  • Home
  • Contact
  • Privacy Policy
  • Terms & Conditions

© 2024 – datacenternews.tech – All rights reserved

Welcome Back!

Sign in to your account

Lost your password?
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.
You can revoke your consent any time using the Revoke consent button.