SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Daniel Carneiro Shell Script Parte VI
Exemplos simples ,[object Object],ls  |  wc  -l find  |  wc  -l find  -type f |  wc  -l ,[object Object],fortune  |  tee   temp  ;  wc  temp;  rm  -f temp temp =$( fortune ); echo  $temp ; echo  $temp  |  wc ,[object Object],PS1 ="[ @: ( git   branch  2> /dev/null |  grep -e  ' ' |  sed  's/^...*/{}/') ]  "
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
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
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
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
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
Start/Stop Script
Start/Stop Script
Start/Stop Script
Obrigado

Weitere ähnliche Inhalte

Was ist angesagt?

All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
 

Was ist angesagt? (20)

Git Sensitive Data
Git Sensitive DataGit Sensitive Data
Git Sensitive Data
 
TDDBC お題
TDDBC お題TDDBC お題
TDDBC お題
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Windows shutdown virus source code c++
Windows shutdown virus source code c++Windows shutdown virus source code c++
Windows shutdown virus source code c++
 
Tgh.pl
Tgh.plTgh.pl
Tgh.pl
 
Combine vs RxSwift
Combine vs RxSwiftCombine vs RxSwift
Combine vs RxSwift
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
 
PHPerのためのPerl入門@ Kansai.pm#12
PHPerのためのPerl入門@ Kansai.pm#12PHPerのためのPerl入門@ Kansai.pm#12
PHPerのためのPerl入門@ Kansai.pm#12
 
NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline Tutorial
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 
Hashing endereçamento aberto - main
Hashing endereçamento aberto - mainHashing endereçamento aberto - main
Hashing endereçamento aberto - main
 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
 
Hands on Hadoop
Hands on HadoopHands on Hadoop
Hands on Hadoop
 
01 คำสั่งแสดงผล ในภาษาซี
01 คำสั่งแสดงผล ในภาษาซี01 คำสั่งแสดงผล ในภาษาซี
01 คำสั่งแสดงผล ในภาษาซี
 
Crack.ba
Crack.baCrack.ba
Crack.ba
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Linear queue
Linear queueLinear queue
Linear queue
 
What is suid, sgid and sticky bit
What is suid, sgid and sticky bit  What is suid, sgid and sticky bit
What is suid, sgid and sticky bit
 

Ähnlich wie Shell Scripting

Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
oscon2007
 
Marko Gargenta_Remixing android
Marko Gargenta_Remixing androidMarko Gargenta_Remixing android
Marko Gargenta_Remixing android
Droidcon Berlin
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2
ady36
 
Dtrace и немного магии
Dtrace и немного магииDtrace и немного магии
Dtrace и немного магии
Dan Kruchinin
 

Ähnlich wie Shell Scripting (20)

Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
Naughty And Nice Bash Features
Naughty And Nice Bash FeaturesNaughty And Nice Bash Features
Naughty And Nice Bash Features
 
Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
 
Marko Gargenta_Remixing android
Marko Gargenta_Remixing androidMarko Gargenta_Remixing android
Marko Gargenta_Remixing android
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Keynote 1 - Engineering Software Analytics Studies
Keynote 1 - Engineering Software Analytics StudiesKeynote 1 - Engineering Software Analytics Studies
Keynote 1 - Engineering Software Analytics Studies
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-Specificity
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-Specificity
 
Noah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku SecretsNoah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku Secrets
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2
 
What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017
 
Performance Wins with BPF: Getting Started
Performance Wins with BPF: Getting StartedPerformance Wins with BPF: Getting Started
Performance Wins with BPF: Getting Started
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
Dtrace и немного магии
Dtrace и немного магииDtrace и немного магии
Dtrace и немного магии
 
Bash tricks
Bash tricksBash tricks
Bash tricks
 
Capital onehadoopclass
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclass
 

Mehr von dcarneir

Mehr von dcarneir (13)

Introdução ao desenvolvimento em hardware
Introdução ao desenvolvimento em hardwareIntrodução ao desenvolvimento em hardware
Introdução ao desenvolvimento em hardware
 
Redshift
RedshiftRedshift
Redshift
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
Certificados digitais
Certificados digitaisCertificados digitais
Certificados digitais
 
Awk
AwkAwk
Awk
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
FLOSS
FLOSSFLOSS
FLOSS
 
IPv6
IPv6IPv6
IPv6
 
Regex
RegexRegex
Regex
 
Bancos de dados No-SQL e afins
Bancos de dados No-SQL e afinsBancos de dados No-SQL e afins
Bancos de dados No-SQL e afins
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

Shell Scripting

  • 1. Daniel Carneiro Shell Script Parte VI
  • 2.
  • 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

Hinweis der Redaktion

  1. tempo de execução: 16s versus 91m find procura subdirs
  2. Diferença entre ' e “