Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOpsSchool!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Shell Bash Scripting: Assignment & Excercise – 11


Write a Shell Bash Script for check if a provided number is Armstrong or not


Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
s9py
s9py
2 years ago

#Your’s is wrong and works only for 3 digits but this one works flawlessly
#!/bin/bash

read -p “Enter Number:” num

temp=$num
arm=0
count=${#num}

if [ $num -lt 10 ]
then
    echo “$num is armstrong number (1-9)”
else
    while [ $num -gt 0 ]
    do
        rem=$((num%10))
        arm=$((arm + rem**count))
        num=$((num/10))
    done

    if [ $arm -eq $temp ]
    then
        echo “$arm = $temp Armstrong Number!”
    else
        echo “$arm != $temp Not a Armstrong Number!”
    fi
fi

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

1
0
Would love your thoughts, please comment.x
()
x