Saturday, 24 May 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  3 Ways to Streamline Your Payroll Process

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

Team Behind Top Lending Protocol Launches Suilend on Sui

Grand Cayman, Cayman Islands, March eleventh, 2024, Chainwire The Suilend lending protocol is Solend’s first…

March 12, 2024

BrainChip debuts edge AI box with partner ecosystem for gesture, security and vision

BrainChip has launched the Akida Edge AI Field, a compact AI/ML processing equipment for varied…

January 8, 2025

AI Infra Summit 2025 – HostingJournalist.com

The AI Infra Summit 2025 (previously often known as the AI {Hardware} Summit) is the…

April 8, 2025

Potential challenges faced by BTC miners due to Norway’s new data center legislation

Norway is introducing new laws to manage information facilities and oversee BTC miners, making it…

April 16, 2024

Microsoft releases Phi-4 language model on Hugging Face

Microsoft has formally launched its newest language mannequin, Phi-4, on the AI repository Hugging Face.…

January 9, 2025

You Might Also Like

Pair, combine, two puzzle pieces that fit together
Global Market

Six vendor platforms to watch

By saad
Lumen Finalizes $5.75B Sale of Quantum Fiber Business to AT&T
Global Market

Lumen Finalizes $5.75B Sale of Quantum Fiber Business to AT&T

By saad
Bain Capital launches hscale for EMEA hyperscale roll-out
Global Market

Bain Capital launches hscale for EMEA hyperscale roll-out

By saad
KI, KI-Experte
Global Market

Agentic AI, LLMs and standards big focus of Red Hat Summit

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.OkNoPrivacy policy
You can revoke your consent any time using the Revoke consent button.Revoke consent