1 / 16

Lab 8

Lab 8. Shell Script. Reference: Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook http://www.freeos.com/guides/lsst/index.html. if condition. if condition which is used for decision making in shell script, If given condition is true then command1 is executed . Syntax :

carol
Download Presentation

Lab 8

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 8 Shell Script Reference: Linux Shell Scripting Tutorial v1.05r3A Beginner's handbook http://www.freeos.com/guides/lsst/index.html

  2. if condition if condition which is used for decision making in shell script, If given condition is true then command1 is executed. Syntax: if condition then command1... fi

  3. if condition

  4. test command or [ expr ] - -True  return zero(0) Is used to see if an expression is true - -Falsereturns nonzero Syntax:test expression OR [ expression ] Run it as follows:

  5. test command or [ expr ]

  6. test command or [ expr ]

  7. test command or [ expr ]

  8. if …else…fi If given condition is true then command1 is executed otherwise command2 is executed. Syntax: if condition then condition else if condition is not true then execute all commands up to fi fi

  9. if …else…fi

  10. Special shell variables $0…$9 Positional parameters or command line arguments myscript $0 foo $1 Bar$2 $#tells you how many parameter your script was given

  11. if …else…fi Syntax: if condition Then if condition then ..... .. do this else .... .. do this fi else ... ..... do this fi

  12. Nested if-else-fi

  13. Multilevel if-then-else Syntax: if condition then condition is zero (true - 0) execute all commands up to elif statement elif condition1 then condition1 is zero (true - 0) execute all commands up to elif statement elif condition2 then condition2 is zero (true - 0) execute all commands up to elif statement else None of the above condtion,condtion1,condtion2 are true (i.e. all of the above nonzero or false) execute all commands up to fi fi

  14. for Loop Syntax: for { variable name } in { list } Do execute one for each item in the list until the list is not finished (And repeat all statement between do and done) done

  15. for Loop

More Related