Sunday, 14 Dec 2025
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 > Examining the many ways to run loops on Linux
Global Market

Examining the many ways to run loops on Linux

Last updated: September 28, 2024 7:44 am
Published September 28, 2024
Share
abstract background light blue
SHARE

You might use a loop like these proven beneath to run by the letters of the alphabet or a sequence of numbers.

$ for x in a..z
do
    echo $x
performed

$ for x in 1..11; do     echo $x; performed

The for command beneath would show calendars for the final three months of the present yr.

$ yr=`date +%Y`; for month in 10..12; do cal $month $yr;  performed

The script beneath loops by all of the months of the yr.

$ for month in `locale mon | sed 's/;/ /g'`; do   echo $month; performed
January
February
March
April
Might
June
July
August
September
October
November
December

Utilizing whereas loops

Whereas loops preserve looping so long as the situation that they’re set as much as monitor is true. Right here’s an instance:

#!/bin/bash

n=1

whereas [ $n -le 4 ]
do
    echo $n
    ((n++))
performed

The script above increments and shows the worth of $n so long as it’s lower than or equal to 4. You will get some time loop to run eternally (i.e., till the system crashes, you sign off, or somebody kills your script) utilizing “whereas true” as proven beneath. The sleep command ensures that it doesn’t run 1000’s of occasions earlier than you may have an opportunity to cease it.

#!/bin/bash

whereas true
do
    echo -n "Nonetheless operating at "
    date
    sleep 10
performed

The script beneath will run so long as the consumer who it’s ready for has not but logged into the system. This may be useful if you’re ready for a co-worker to deal with an issue earlier than you’ll be able to transfer forward along with your job. It checks as soon as a minute to see if the consumer has logged in but.

See also  Three options for wireless power in the enterprise

Source link

TAGGED: Examining, Linux, loops, Run, Ways
Share This Article
Twitter Email Copy Link Print
Previous Article Grayscale Arc logo on pink and blue background. Arc browser adds security bulletins and bug bounties
Next Article Eaton opens new data centre power modules factory Eaton opens new data centre power modules factory
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

AMD warns of new Meltdown/Spectre-like CPU bugs

AMD has issued an alert to customers of a newly found type of side-channel assault…

July 11, 2025

How to examine files on Linux

$ ls -ld TOPs-rw-r--r--. 1 jdoe jdoe 9571 Oct 18 12:58 TOPs$ ls -ldh TOPs-rw-r--r--.…

October 24, 2024

Check Point Simplifies Cloud Application Security with AI-Powered WAFaaS

The New CloudGuard WAF-as-a-Service affords a totally managed, scalable resolution empowering companies to navigate the…

June 15, 2024

Zenlayer’s network infrastructure expansion boosts Asia’s AI future

Zenlayer, a hyperconnected cloud firm has upgraded its software-defined community throughout Asia to offer ultra-low…

September 20, 2024

Nscale offers AMD AI chips-as-a-service in green data center

Lee additionally mentioned the implications for numerous stakeholders within the AI trade. “Builders should perceive…

May 5, 2024

You Might Also Like

3D Rendering of digital binary data on microchip with glow circuit board background. Concept of for deep machine learning, crypto currency, hi tech product uses. Big data visualization, cpu processing
Global Market

How can Arm gain enterprise acceptance?

By saad
Two futuristic-looking hands shaking.
Global Market

Most significant networking acquisitions of 2025

By saad
AI training
Global Market

Cybersecurity skills matter more than headcount in an AI era: ISC2 study

By saad
shutterstock 2291065933 space satellite in orbit above the Earth white clouds and blue sea below
Global Market

Aetherflux joins the race to launch orbital data centers by 2027

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.