1 / 9

Lab # 10

Lab # 10. Shell Script con. while loop. Syntax : while [ condition ] do command1 command2 command3 .. .... done. while loop. The case Statement. Syntax : case $variable-name in pattern1) command ... command;; pattern2) command

hei
Download Presentation

Lab # 10

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. Lab # 10 Shell Script con.

  2. while loop Syntax: while [ condition ] do command1 command2 command3 .. .... done

  3. while loop

  4. The case Statement Syntax: case $variable-name in pattern1) command ... command;; pattern2) command ... command;; patternN) command ... command;; *) command ... command;; esac

  5. Write shell script using for loop to print the following patterns . 122333444455555 for (( i=1; i<=5; i++ )) do for (( j=1; j<=i; j++ )) do echo -n "$i" done echo ”“ done

  6. Write script to print numbers as 5,4,3,2,1, using while loop. The biggest number is supplied as command line argument. i=$1 while test $i != 0 do echo –n "$i ," i=`expr $i - 1` done echo " "

  7. Write script to implement get options statement, your script should understand following command line argument :script-name -c -d -m –eWhere options work as-c clear the screen-l show list of files in current working directory-h display history file-d display the date

  8. if [ $# -ne 1 ] then echo " Enter one argument –c , –l , –h or -d" else case $1 in " -c ") clear;; " -l ") ls -l;; " -h ") history;; " -d ") date ;; *) echo " Invalid option ";; esac fi

More Related