Monday, 9 Feb 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 yin and yang of AI and data management

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

Penomo & Hoovest Financial Group Partner For Tokenized AI & Infrastructure Institutional Finance

Berlin, Germany, March fifth, 2025, FinanceWire Penomo has fashioned a strategic partnership with Hoovest Financial…

March 5, 2025

Current laws are fit for the AI era

As ministers push to loosen guidelines to hurry up AI adoption, The Law Society argues…

January 6, 2026

English soccer to debut semi-automated offside technology in FA Cup

Credit score: Pixabay/CC0 Public Area English soccer will use semi-automated offside expertise for the primary…

February 16, 2025

Airedale by Modine to open new manufacturing plant in Bradford

Airedale by Modine has acquired a brand new manufacturing web site in Bradford, West Yorkshire…

May 12, 2024

AWS debuts advanced RAG features for structured, unstructured data

Be a part of our day by day and weekly newsletters for the newest updates…

December 5, 2024

You Might Also Like

Can air cooling survive the AI era?
Global Market

Can air cooling survive the AI era?

By saad
System administrator typing supercomputer hub disaster recovery plan on laptop to provide fast restoration of service, limiting damage and minimizing interruptions to normal operations
Global Market

8 hot networking trends for 2026

By saad
Shutterstock Germany Only - News - Intel Factory Germany September 2024
Global Market

Intel sets sights on data center GPUs amid AI-driven infrastructure shifts

By saad
Side view of technician or engineer with headset and laptop standing in industrial factory.
Global Market

Is private 5G/6G important after all?

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.