Lab 8 - PowerPoint PPT Presentation

carol
lab 8 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Lab 8 PowerPoint Presentation
play fullscreen
1 / 16
Download Presentation
172 Views
Download Presentation

Lab 8

- - - - - - - - - - - - - - - - - - - - - - - - - - - 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