Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Daniel Carneiro Shell Script Parte VI
Exemplos simples <ul><li>Contar arquivos </li></ul>ls  |  wc  -l find  |  wc  -l find  -type f |  wc  -l <ul><li>Manipular...
Para remover muitos arquivos (500000+): rm   f* bash: /bin/rm: Lista de argumentos muito longa for   i   in   f*;   do   r...
Buscar um aplicativo e matá-lo ps aux  (listar processos) USER  PID %CPU %MEM  VSZ  RSS TTY  STAT START  TIME COMMAND root...
Buscar um aplicativo e matá-lo pids= $(   ps  aux|   grep  pts/1|   grep   -v  grep|   tr   -s  &quot; &quot;|   cut   -d ...
Install Script #!/bin/bash SID= ${1:-$ORACLE_SID} echo Creating instance  $SID read  -r -p   &quot;Are you sure? [y/N] &qu...
Install Script mkdir  $SID cp  pass.sql  $SID cat  init.ora| sed -e   &quot;s/ORACLE_SID/ $SID /g&quot;  >  $SID /init.ora...
Start/Stop Script
Start/Stop Script
Start/Stop Script
Obrigado
Upcoming SlideShare
Loading in …5
×

Shell Scripting

2,042 views

Published on

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

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

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Shell Scripting

  1. 1. Daniel Carneiro Shell Script Parte VI
  2. 2. Exemplos simples <ul><li>Contar arquivos </li></ul>ls | wc -l find | wc -l find -type f | wc -l <ul><li>Manipular uma saída </li></ul>fortune | tee temp ; wc temp; rm -f temp temp =$( fortune ); echo $temp ; echo $temp | wc <ul><li>Branch do git no prompt </li></ul>PS1 =&quot;[ u@h:W $( git branch 2> /dev/null | grep -e '* ' | sed 's/^..(.*)/{1}/') ]$ &quot;
  3. 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. 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. 5. Buscar um aplicativo e matá-lo pids= $( ps aux| grep pts/1| grep -v grep| tr -s &quot; &quot;| cut -d &quot; &quot; -f 2 ) for i in $pids; do kill $i; done
  6. 6. Install Script #!/bin/bash SID= ${1:-$ORACLE_SID} echo Creating instance $SID read -r -p &quot;Are you sure? [y/N] &quot; response response= ${response,,} # tolower if [[ $response =~ ^(yes|y)$ ]]; then echo creating... $SID else exit fi
  7. 7. Install Script mkdir $SID cp pass.sql $SID cat init.ora| sed -e &quot;s/ORACLE_SID/ $SID /g&quot; > $SID /init.ora cat CreateDB.sql| sed -e &quot;s/ORACLE_SID/ $SID /g&quot; > $SID /CreateDB.sql cat CreateDBFiles.sql| sed -e &quot;s/ORACLE_SID/ $SID /g&quot; > $SID /CreateDBFiles.sql cat CreateDBCatalog.sql| sed -e &quot;s/ORACLE_SID/ $SID /g&quot; > $SID /CreateDBCatalog.sql cat postDBCreation.sql| sed -e &quot;s/ORACLE_SID/ $SID /g&quot; > $SID /postDBCreation.sql
  8. 8. Start/Stop Script
  9. 9. Start/Stop Script
  10. 10. Start/Stop Script
  11. 11. Obrigado

×