Posts

Showing posts with the label shell script

Shell Script To Find Out Biggest Number Form Given Three Numbers - The Coding Shala

Home >> Scripting >> Biggest number Shell Script To Find Out Biggest Number Form Given Three Numbers Write a shell script to find out the biggest number form given three numbers. Numbers are supplied by the command line argument? Code:  #! / bin / bash if [ $# - ne 3 ] then echo "enter three argument" exit 1 fi if [ $ 1 - gt $ 2 ] && [ $ 1 - gt $ 3 ] then echo "$1 is biggest number" elif [ $ 2 - gt $ 1 ] && [ $ 2 - gt $ 3 ] then echo "$2 is the biggest number" elif [ $ 3 - gt $ 1 ] && [ $ 3 - gt $ 2 ] then echo "$3 is biggest number" else echo "all numbers are equal" fi Other Posts You May Like Shell script to print sum of all digits Shell script to add two numbers Shell script to find factorial Shell script to generate Fibonacci series Shell script to create a simple calculator Please leave a comment below if you like this post...

Shell Script to Print Numbers in Descending Order - The Coding Shala

Home >> Scripting >> Descending order of a number Shell Script to Print Numbers in Descending Order Write a shell script to print numbers in descending order using a while loop? Code:  #! / bin / bash i = 5 while test $ i != 0 do echo "$i" i =`expr $ i - 1 ` done Other Posts You May Like Shell script to print sum of all digits Shell Script to add two numbers Shell Script to find a factorial Shell script to print a number in reverse order Shell script to create a simple calculator Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Shell Script to Create a Simple Calculator - The Coding Shala

Home >> Scripting >> simple calculator Shell Script to Create a Simple Calculator Write a shell script to create a simple calculator using a switch-case statement? Code:  #! / bin / bash echo "simple calculator" sum = 0 i = "y" echo "enter first number" read n1 echo "enter second number" read n2 while [ $ i = "y" ] do echo "1.Addition" echo "2.Subtraction" echo "3.Multiplication" echo "4.Division" echo "Enter choice" read ch case $ch in 1 ) sum =$(echo " $n1 + $n2" | bc - l) echo "Addition is =" $ sum ;; 2 ) sum =$(echo "$n1 - $n2" | bc - l) echo "Sub is =" $ sum ;; 3 ) sum =$(echo "$n1 * $n2" | bc - l) echo "Mul is =" $ sum ;; 4 ) sum =$(echo "$n1 / $n2" | bc - l) echo "div is =" $ sum ;; * )echo "invalid choice" esac echo "Do y...

Shell Script to print given number in reverse order - The Coding Shala

Home >> Scripting >> reverse order of a number Shell Script to print given number in reverse order Write a shell script to print given the number in reverse order? Code:  #! / bin / bash n=$ 1 rev= 0 tmp= 0 while [ $n - gt 0 ] do tmp=`expr $n % 10 ` rev=`expr $rev \* 10 + $tmp` n=`expr $n / 10 ` done echo "reverse no is $rev" Other Posts You May Like Shell Script to print sum of all digits Shell script to find the sum, product, and the average of given numbers Shell script to create a simple calculator Shell script to find factorial Shell script to add two numbers Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Shell Script to print sum of all digits of a given number - The Coding Shala

Home >> Scripting >> Sum of all digits Shell Script to print sum of all digits of a given number Write a shell script to print the sum of all digits of a given number? Code:  #! / bin / bash n=$ 1 sum = 0 tmp= 0 while [ $n - gt 0 ] do tmp=`expr $n % 10 ` sum =`expr $ sum + $tmp` n=`expr $n / 10 ` done echo "sum of digits is $sum" Other Posts You May Like Shell script to find the sum, product, and the average of a number Shell script to print numbers in descending order Shell script to find factorial of a number Shell script to add two numbers Shell script to generate Fibonacci series Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Shell Script to find sum, product and average of given numbers - The Coding Shala

Home >> Scripting >> Sum, product and average Shell Script to find the sum, product, and the average of given numbers Read four integer numbers from the user and find the sum, product, and average of these four numbers? Code:  #! / bin / bash echo "enter four integers" read a b c d sum =$(echo "$a + $b + $c + $d" | bc - l) average=$(echo "$sum / 4" | bc - l) product=$(echo "$a * $b * $c * $d" | bc - l) echo "sum = $sum" echo "Average = $average" echo "Product = $product" Other Posts You May Like Shell script to print sum of the digits of a number Shell Script to print number in descending order Shell script to find out biggest number from three numbers Shell script to find out factorial of a number Shell Script to create a simple calculator Please leave a comment below if you like this post or found some error, it will help me to improve my content. ...

Shell Script to Display the digits which are at odd positions in a given 5-digit number - The Coding Shala

Home >> Scripting >> Odd position digits Shell Script to Display the digits which are at odd positions in a given 5-digit number Display the digits which are at odd positions in a given 5-digit number.   Example: number is 23786 output - 276. Code:  #! / bin / bash echo "enter 5 digit number" read number n= 1 while ((n < = 5 )) do a =`echo $number | cut - c $n` echo - n "$a" n=`expr $n + 2 ` done echo " " Other Posts You May Like Shell script to add two numbers using command line argument Shell script to generate Fibonacci series Shell script to find factorial of a number Shell script to print a number in reverse order Shell script to create a simple calculator Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Shell Script to find factorial of a number - The Coding Shala

Home >> Scripting >> find factorial Shell Script to find factorial of a number Write a shell script program to find the factorial value of the given input number? Code:  #! / bin / bash factorial () { ans =$ 1 if (( ans < = 2 )); then echo $ ans else f=$(( ans - 1 )) f=$( factorial $f) f=$((f * ans )) echo $f fi } read - p "enter number" n if ((n == 0 )); then echo "1" else factorial $n fi Other Posts You May Like Shell Script to print numbers in descending order Shell script to find out biggest number from given three number Shell script to add two numbers Shell script to generate Fibonacci series Shell script to print sum of the digits of a number Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Shell Script to generate fibonacci series - The Coding Shala

Home >> Scripting >> Fibonacci Series Shell Script to generate Fibonacci series Write a shell script to generate and display the Fibonacci series? Code:  #! / bin / bash c= 2 a = 1 b= 1 d= 0 echo "enter the number of elements" read n echo "$a" echo "$b" while ((c < n)) do d=$(( a + b)) echo "$d" a =$b b=$d c=$((c + 1 )) done Other Posts You May Like Shell Script to add two numbers using command line argument Shell Script to generate factorial Shell script to print sum of all digits of a number Shell script to print a number in reverse order Shell Script to create a simple calculator Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Shell Script To Add Two Numbers Using Command Line Arguments - The Coding Shala

Home >> Scripting >> Add two numbers Shell Script To Add Two Numbers Using Command Line Arguments Write a shell script to add two numbers supplied as a command-line argument? Code:  #! / bin / bash if [ $# - ne 2 ] then echo "enter two arguments" else sum =$(echo "$1 + $2" | bc) echo "$sum " fi Other Posts You May Like Shell Script to generate fibonacci series Shell Script to find factorial of a number Shell Script to print sum of all digits of a given number Shell Script to print a number in reverse order Shell Script to create a simple calculator Please leave a comment below if you like this post or found some error, it will help me to improve my content.