Shell Scripting

796
-1

Published on

Quarta parte da apresentação sobre Shell Scripting realizada na Bluesoft

Confira o video em http://www.vimeo.com/17606525

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
796
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • else = default = *) ;;* Shell pattern
  • Shell Scripting

    1. 1. Daniel Carneiro Shell Script Parte IV
    2. 2. Case <ul><li>Sintaxe: </li><ul><li>case word in pattern | pattern ) statements ;;& pattern | pattern ) statements ;; *) statements ;; esac </li></ul></ul>
    3. 3. Case <ul><li>Ex1: </li></ul>case $opt in start ) echo “inicia o processo” ;; stop ) echo “encerra o processo” ;; *) echo “comando desconhecido” ;; esac
    4. 4. Case <ul><li>Ex1: </li></ul>case $filename in *.c | *.java | *.py ) echo arquivo fonte em C / Java / Python ;; *.o | *.class | *.pyc | *.pyo ) echo arquivo compilado ;; *) echo outro tipo de arquivo ;; esac
    5. 5. for <ul><li>Sintaxe: </li><ul><li>for name in word... ; do list; done
    6. 6. for name in word... ; do list done
    7. 7. for ((expr1; expr2; expr3)) ; do list; done
    8. 8. for ((expr1; expr2; exp3)) ; do list done </li></ul></ul>
    9. 9. for <ul><li>Exemplos: </li><ul><li>for nome in *.xyz ; do rm $nome; done
    10. 10. for nome in [ab]* ; do echo $nome; done
    11. 11. for nome in a{b,c,d} ; do echo $nome; done
    12. 12. for ((n=0; n<10; n++)) ; do echo $n; done
    13. 13. for n in $(seq 0 9) ; do echo $n; done </li></ul></ul>
    14. 14. while/until <ul><li>Sintaxe: </li><ul><li>while list; do list; done
    15. 15. until list; do list; done
    16. 16. Obs.: </li><ul><li>0 == True
    17. 17. until é avaliado no inicio do loop </li></ul></ul></ul>
    18. 18. while/until <ul><li>Exemplo: </li></ul>inicio=$1 fim=$2 while [ $inicio -le $fim ] ; do echo $inicio $inicio=$ (( inicio+2 )) done
    19. 19. break / continue <ul><li>break -> interrompe o processamento do laço
    20. 20. continue -> volta ao inicio do laço
    21. 21. Ex: </li><ul><li>for n in $(seq 1 10); do echo $n if [ $n -eq 5 ]; then break ; fi done </li></ul></ul>
    22. 22. Here Documents <ul><li>Sintaxe: </li><ul><li><< [ - ] delimiter text delimiter </li></ul><li>Exemplo: </li><ul><li>var1= << EOF Texto1 Texto2 EOF </li></ul></ul>
    23. 23. Header String <ul><li>Sintaxe: </li><ul><li>#! interpretador </li></ul><li>Exemplo: </li><ul><li>#! /bin/bash #! /usr/bin/bash #! /usr/bin/python #! /usr/bin/perl #! /usr/bin/env bash </li></ul></ul>

    ×