Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Processando textos enormes com ferramentas "Unix"
Search
Luiz Menezes
February 11, 2017
77
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Processando textos enormes com ferramentas "Unix"
Palestra dada no evento "Linux em Prosa" do sancaLUG.
Luiz Menezes
February 11, 2017
Transcript
21 slides
processando textos enormes com ferramentas "unix"
oi! eu sou o luiz me encontre em @luiz_amf github.com/lamenezes
abrir/ler e processar textões arquivos de texto com mais de
8 mil 10 milhões de linhas (>4 GB) o problema
None
“ Write programs that do one thing and do it
well Write programs to work together. Write programs to handle text streams, because that is a universal interface. "Unix Philosophy" por Peter Salus
fazer uma coisa e fazer bem a caixa de ferramentas
cat concatenate files and print ▷ visualizar arquivos texto ▷
exemplo $ cat foo.txt
less ▷ visualizar arquivos texto ▷ permite navegação ▷ lê
arquivo enquanto executa ▷ exemplo $ less foo.txt
cp copy ▷ sempre tenha um backup de seus dados
▷ exemplo $ cp foo.txt backup.txt
head & tail ▷ imprime X linhas do arquivo ▷
dividir e conquistar ▷ exemplos $ head foo.txt -n 20 $ tail foo.txt -n 50
▷ qual o tamanho da bronca? ▷ calcula do arquivo
◦ linhas ◦ caracteres/bytes ◦ palavras ▷ exemplo $ wc foo.txt wc word count
▷ remove partes de cada linha de um arquivo ▷
exemplo $ cut -f2,3-5 foo.txt cut
▷ editor "completo" ◦ substituição/remoção de caracteres ◦ duplica linhas
◦ remoção de linhas ◦ busca ▷ exemplo $ sed 's/foo/bar/' foo.txt sed stream editor
▷ busca ▷ exemplo $ grep agulha palheiro.txt grep global
search a regular expression and print
trabalhar bem em conjunto a interface universal de stream de
textos
pipes ▷ encadeamento de comandos
cat <arquivo> | tr <de> <para> ▷ traduz caracteres ▷
deleta ▷ "aperta" tr translate or delete characters
▷ busca com filtros múltiplos cat random.csv | grep AC
| grep "Sr\." cat random.csv | grep João | grep AL ▷ busca + remoção de palavras cat random.csv | grep AC | sed "s/Dr. //" cat random.csv | grep GO | sed "s/Sr. //" pipes
▷ visualizar consumo de memória dos programas ps aux |
sed "s/ \+/\t/g" | cut -f 4,11- | less pipes
obrigado! @luiz_amf github.com/lamenezes
Credits Special thanks to all the people who made and
released these awesome resources for free: ▷ Presentation template by SlidesCarnival
More Decks by Luiz Menezes
See All by Luiz Menezes
async é bom, async eu gosto
luizmenezes
0
64
Testando aplicações web com py.test e selenium
luizmenezes
0
160
Python 3 Orientado a Objetos
luizmenezes
3
340
Expondo o Raspberry Pi via servidor web
luizmenezes
0
110
Workshop Django
luizmenezes
2
270
Bottle Admin
luizmenezes
0
120
IoT, Raspberry Pi e Python
luizmenezes
1
95
Coding Dojo
luizmenezes
0
82
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
880
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
570
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
The Cost Of JavaScript in 2023
addyosmani
56
10k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
570
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
The Curious Case for Waylosing
cassininazir
1
610
How to Talk to Developers About Accessibility
jct
2
620
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
Heart Work Chapter 1 - Part 1
lfama
PRO
11
37k
YesSQL, Process and Tooling at Scale
rocio
174
15k