Friday, 10 Apr 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 > Making a case for case statements on Linux
Global Market

Making a case for case statements on Linux

Last updated: May 23, 2024 5:55 am
Published May 23, 2024
Share
Letters, type, code
SHARE

#!/bin/bash

echo -n "enter the variety of equal sides that the form has> "
learn numsides

# make sure that reply is numeric
re="^[0-9]+$"
if ! [[ $numsides =~ $re ]] ; then
   echo "error: Not a quantity" >&2; exit 1
fi

if [ $numsides -lt 3 ]; then
    echo "Sorry, however that might NOT be a geometrical form"
elif [ $numsides == 3 ]; then
    echo triangle
elif [ $numsides == 4 ]; then
    echo sq. or rectangle
elif [ $numsides == 5 ]; then
    echo pentagon 
elif [ $numsides == 6 ]; then
    echo hexagon 
elif [ $numsides == 7 ]; then
    echo heptagon 
elif [ $numsides == 8 ]; then
    echo octagon 
elif [ $numsides == 9 ]; then
    echo nonagon 
elif [ $numsides == 10 ]; then
    echo decagon 
elif [ $numsides == 11 ]; then
    echo hendecagon 
elif [ $numsides == 12 ]; then
    echo dodecagon 
elif [ $numsides -gt 12 ]; then
    echo "Hmm, you’d higher ask Google"
fi

Utilizing case statements, however, makes your code a lot easier to place collectively and far simpler to learn.

#!/bin/bash

echo -n "enter the variety of equal sides that the form has> "
learn numsides

# make sure that reply is numeric
re="^[0-9]+$"
if ! [[ $numsides =~ $re ]] ; then
   echo "error: Not a quantity" >&2; exit 1
fi

case "$numsides" in
    0-2) echo "Sorry, however that might NOT be a geometrical form";;
    3) echo triangle;;
    4) echo sq. or rectangle;;
    5) echo pentagon;;
    6) echo hexagon;;
    7) echo heptagon;;
    8) echo octogon;;
    9) echo nonagon;;
    10) echo decagon;;
    11) echo hendecagon;;
    12) echo dodecaggon;;
    *) echo "Hmm, you’d higher ask Google"
esac

Every section within the case assertion should finish with two semicolons. Nonetheless, you would use a number of instructions separated by semicolons and solely use the double semicolons on the finish od that section.

See also  How connected infrastructure can boost data centre sustainability

Wrap-up

Discover how a lot simpler case instructions are to arrange and preserve. You’ll be able to present any variety of attainable values at the price of one line every.

Source link

TAGGED: case, Linux, Making, statements
Share This Article
Twitter Email Copy Link Print
Previous Article 2 Power Utilities Want Data Centers To Foot The Bill For Billions In Grid Upgrades 2 Power Utilities Want Data Centers To Foot The Bill For Billions In Grid Upgrades
Next Article New flexible film detects eyelash proximity in blink-tracking glasses New flexible film detects eyelash proximity in blink-tracking glasses
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

Digital divide – Virginia Business

Knowledge middle increase sparks opposition, regulation bids Printed March 28, 2024 by Elizabeth Cooper State…

March 29, 2024

Researchers create tiny nuclear-powered battery thousands of times more efficient than predecessors

Two totally different architectures of radiophotovoltaic batteries. Credit score: Nature (2024). DOI: 10.1038/s41586-024-07933-9 A workforce…

September 19, 2024

CodeSignal targets skills gap with ‘Learn’ platform amidst tech talent crunch

CodeSignal, a leading assessment platform for evaluating the technical skills of engineering candidates, has announced…

February 9, 2024

Enterprises reevaluate virtualization strategies amid Broadcom uncertainty

This dilemma of whether or not to soak up the Broadcom value hikes or embark…

March 18, 2025

Sybill’s AI reads customer behavior to automate sales workflows

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

July 31, 2024

You Might Also Like

Zoho confirms launch plans for UK data centre
Global Market

Zoho confirms launch plans for UK data centre

By saad
Cloud Hyperscaler Concept - Hyperscale Computing - Cloud Architecture that Scales with Increasing Demand - 3D Illustration
Global Market

Neoclouds gain momentum in a supply-constrained world

By saad
Stargate comes to the UK, with OpenAI, Nvidia and Nscale
Global Market

OpenAI puts Stargate UK on pause, cites ‘high energy costs’

By saad
open source digital screen
Global Market

New v2 UALink specification aims to catch up to NVLink

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.