Saturday, 28 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 > 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  SWiRL: The business case for AI that thinks like your best problem-solvers

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

Freedx Secures Key DASP License in El Salvador

San Salvador, El Salvador, April eighth, 2025, Chainwire Dubai, UAE/ San Salvador, El Salvador, Freedx, a centralized…

April 8, 2025

Researcher reveals ‘catastrophic’ security flaw in the Arc browser

Arc has a function known as Boosts that lets you customise any web site with…

September 20, 2024

Pressure to implement AI raises IT tensions

Enterprise spending on generative AI companies, software program and infrastructure will explode over the next…

February 14, 2024

Fast-growing NetIX selects Telehouse London Docklands for point-of-presence

To allow its fast world-wide enlargement, NetIX, one of many fastest-growing Web Exchanges on this…

February 10, 2025

Workflow Raises $3M in Pre-Seed Funding

Workflow, a London, UK-based firm constructing AI software program for design, advertising and marketing, and…

November 15, 2024

You Might Also Like

AI
Global Market

OpenAI launches stateful AI on AWS, signaling a control plane power shift

By saad
AI is rewriting the rules of data centre power – who wins?
Global Market

AI is rewriting the rules of data centre power – who wins?

By saad
Spotlight report: Accelerating Data Center Modernization
Global Market

Spotlight report: Accelerating Data Center Modernization

By saad
The next AI race may not be on Earth at all
Global Market

The next AI race may not be on Earth at 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.