• Like
  • Save
Shell Scripting
Upcoming SlideShare
Loading in...5
×
 

Shell Scripting

on

  • 954 views

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

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

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

Statistics

Views

Total Views
954
Views on SlideShare
954
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • else = default = *) ;;* Shell pattern

Shell Scripting Shell Scripting Presentation Transcript

  • Daniel Carneiro Shell Script Parte IV
  • Case
    • Sintaxe:
      • case word in pattern | pattern ) statements ;;& pattern | pattern ) statements ;; *) statements ;; esac
  • Case
    • Ex1:
    case $opt in start ) echo “inicia o processo” ;; stop ) echo “encerra o processo” ;; *) echo “comando desconhecido” ;; esac
  • Case
    • Ex1:
    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
  • for
    • Sintaxe:
      • for name in word... ; do list; done
      • for name in word... ; do list done
      • for ((expr1; expr2; expr3)) ; do list; done
      • for ((expr1; expr2; exp3)) ; do list done
  • for
    • Exemplos:
      • for nome in *.xyz ; do rm $nome; done
      • for nome in [ab]* ; do echo $nome; done
      • for nome in a{b,c,d} ; do echo $nome; done
      • for ((n=0; n<10; n++)) ; do echo $n; done
      • for n in $(seq 0 9) ; do echo $n; done
  • while/until
    • Sintaxe:
      • while list; do list; done
      • until list; do list; done
      • Obs.:
        • 0 == True
        • until é avaliado no inicio do loop
  • while/until
    • Exemplo:
    inicio=$1 fim=$2 while [ $inicio -le $fim ] ; do echo $inicio $inicio=$ (( inicio+2 )) done
  • break / continue
    • break -> interrompe o processamento do laço
    • continue -> volta ao inicio do laço
    • Ex:
      • for n in $(seq 1 10); do echo $n if [ $n -eq 5 ]; then break ; fi done
  • Here Documents
    • Sintaxe:
      • << [ - ] delimiter text delimiter
    • Exemplo:
      • var1= << EOF Texto1 Texto2 EOF
  • Header String
    • Sintaxe:
      • #! interpretador
    • Exemplo:
      • #! /bin/bash #! /usr/bin/bash #! /usr/bin/python #! /usr/bin/perl #! /usr/bin/env bash