1 / 6

Shell Script

Shell Script. Exercises. What is the output of?. $ echo " expr 6 + 5“ expr 6 + 5 $ echo ' expr 6 + 5‘ 11. Write Script to see current date, time, username, and current directory. echo "Current date is `date`“ echo "User is $ USER “ echo "Current directory ` pwd `".

jui
Download Presentation

Shell Script

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Shell Script Exercises

  2. What is the output of? • $ echo "expr 6 + 5“ • expr 6 + 5 • $ echo 'expr 6 + 5‘ • 11

  3. Write Script to see current date, time, username, and current directory. echo "Current date is `date`“ echo "User is $USER“ echo "Current directory `pwd`"

  4. Write shell script that will add two numbers, which are supplied as command line argument, and if this two numbers are not given show error message. if [ $# -ne 2 ] then echo " Enter 2 number to find the sum“ else echo "Sum of $1 and $2 is `expr $1 + $2`“ fi

  5. Write a shell script to find out biggest number from given three numbers. if [ $# -ne 3 ] then echo “Enter three number to compare them" elif [ $1 -gt $2 ] && [ $1 -gt $3 ] ; then echo "$1 is Bigest number" elif [ $2 -gt $1 ] && [ $2 -gt $3 ] ; then echo "$2 is Bigest number" else echo "$3 is Bigest number" fi

  6. Write a shell script to read a number and find whether the number is odd or even. echo -n “Enter a number : “ read n rem=`expr $n % 2` If [ $rem -eq 0 ] then echo “$n is even number” else echo “$n is odd number” fi

More Related