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

Like this? Share it with your network

Share

Shell Scripting

on

  • 2,038 views

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

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

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

Statistics

Views

Total Views
2,038
Views on SlideShare
1,780
Embed Views
258

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 258

http://blog.bluesoft.com.br 239
http://www.bluesoft.com.br 19

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
  • tempo de execução: 16s versus 91m find procura subdirs
  • Diferença entre ' e “

Shell Scripting Presentation Transcript

  • 1. Daniel Carneiro Shell Script Parte VI
  • 2. Exemplos simples
    • Contar arquivos
    ls | wc -l find | wc -l find -type f | wc -l
    • Manipular uma saída
    fortune | tee temp ; wc temp; rm -f temp temp =$( fortune ); echo $temp ; echo $temp | wc
    • Branch do git no prompt
    PS1 ="[ u@h:W $( git branch 2> /dev/null | grep -e '* ' | sed 's/^..(.*)/{1}/') ]$ "
  • 3. Para remover muitos arquivos (500000+): rm f* bash: /bin/rm: Lista de argumentos muito longa for i in f*; do rm $i; done find -name 'f*' -exec rm {} ; for i in $( find -name 'f*'); do rm $i; done
  • 4. Buscar um aplicativo e matá-lo ps aux (listar processos) USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 2792 1648 ? Ss 19:27 0:00 /sbin/init root 2 0.0 0.0 0 0 ? S 19:27 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 19:27 0:01 [migration/0] root 4 0.0 0.0 0 0 ? S 19:27 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S 19:27 0:00 [watchdog/0] root 6 0.0 0.0 0 0 ? S 19:27 0:01 [migration/1] root 7 0.0 0.0 0 0 ? S 19:27 0:00 [ksoftirqd/1] root 8 0.0 0.0 0 0 ? S 19:27 0:00 [watchdog/1] root 9 0.0 0.0 0 0 ? S 19:27 0:00 [events/0] root 10 0.0 0.0 0 0 ? S 19:27 0:00 [events/1] . . . daniel 2762 35.4 2.4 73372 70772 pts/0 Ss 22:12 22:09 bash daniel 12969 0.0 0.0 2716 1040 pts/1 R+ 23:14 0:00 ps aux
  • 5. Buscar um aplicativo e matá-lo pids= $( ps aux| grep pts/1| grep -v grep| tr -s " "| cut -d " " -f 2 ) for i in $pids; do kill $i; done
  • 6. Install Script #!/bin/bash SID= ${1:-$ORACLE_SID} echo Creating instance $SID read -r -p "Are you sure? [y/N] " response response= ${response,,} # tolower if [[ $response =~ ^(yes|y)$ ]]; then echo creating... $SID else exit fi
  • 7. Install Script mkdir $SID cp pass.sql $SID cat init.ora| sed -e "s/ORACLE_SID/ $SID /g" > $SID /init.ora cat CreateDB.sql| sed -e "s/ORACLE_SID/ $SID /g" > $SID /CreateDB.sql cat CreateDBFiles.sql| sed -e "s/ORACLE_SID/ $SID /g" > $SID /CreateDBFiles.sql cat CreateDBCatalog.sql| sed -e "s/ORACLE_SID/ $SID /g" > $SID /CreateDBCatalog.sql cat postDBCreation.sql| sed -e "s/ORACLE_SID/ $SID /g" > $SID /postDBCreation.sql
  • 8. Start/Stop Script
  • 9. Start/Stop Script
  • 10. Start/Stop Script
  • 11. Obrigado