SlideShare a Scribd company logo
grep | sed | awk | xargs | etcPractical *nix utilities(for text processing)
whoami
/awkcatgreptacsedecholsdutestmvsplittaildirjoinwcheadvimtrsortsumcutexpruniqpastekilltee
/LogMega AppFilesDB
pwd | ls | find | teeGNU Coreutilshttp://www.gnu.org/software/coreutils/The takeaway command:man> info coreutils
pwd | ls | find | teeList of files:ls –lls–1ls –latrfind . –name *.txt
pwd | ls | find | teeSeek for a string in a file:grep“cat” file.txtgrep –v “dog” file.txtgrep –i “PaTtErN” file.txtegrep“cat|dog” file.txtzgrep“cat” file.txt.gz
for / xargsDo something with each file:for file in `find . –name *tmp` dorm$file donefind . –name *tmp| xargsrm
pwd | ls | find | teefind + grepfind . -name '*txt' -exec grep-l aaa{} \;find . -name '*txt' | xargsgrep-l aaa
pwd | ls | find | teecatgreptacecholsdutestmvsplittaildirjoinwcheadtrsortsumcutexpruniqpastekilltee
paste
join
sort | uniq
wc
cut
csplit
awksed
sedsfor substitutionsed‘s/cat/dog/’ # cat -> dogsed ‘s/\(a\)\(b\)/\2\1/’# ab-> ba
sedpfor printingsed –n ‘/dog/p’ # print lines that match ‘dog’sed–n ‘/start/,/end/p’# print range
seddto deletesed ‘/dog/d’# delete lines that match ‘dog’sed ‘1,/pattern/d’# delete range
sed| and –e for invocationsed ‘s/a/A/’ | sed ‘s/b/B/’#sed –e ‘s/a/A/’ –e ‘s/b/B/’ #
sed{ .. } to group the commandssed ‘/pattern/ {       s/p/P/       s/e/E/    }’#pattern -> PattErn
sedrto read a filesed ‘/include/ r file.txt’# insert file.txt after includewto write to a filesed‘/pattern/ w file.txt’# write matched lines to a file
sedtris
awkaaabbb cccaaabbbzzzawk '/zzz/'  1.txt  grepzzz    1.txtaaabbbzzz
awkawk'BEGIN{<initializations>}<pattern 1> {<actions>}<pattern 2> {<actions>}... END{<final actions>}'
awkawk'BEGIN{a=0, b=0} /aaa/{a++} /bbb/   {b++}END{printf “%d\t%d”,a,b}'
awkawk'{arr[$2]+=$1} END { for (id in arr) printf "%s\t%d\t\n",id,arr[id]}'
exit@antonarhipov

More Related Content

What's hot (20)

Cscope and ctags
Cscope and ctags
Saikat Megamind
 
Fast and cost effective geospatial analysis pipeline with AWS lambda
Fast and cost effective geospatial analysis pipeline with AWS lambda
Mila Frerichs
 
2015 bioinformatics python_strings_wim_vancriekinge
2015 bioinformatics python_strings_wim_vancriekinge
Prof. Wim Van Criekinge
 
Txjs
Txjs
Peter Higgins
 
Why Python (for Statisticians)
Why Python (for Statisticians)
Matt Harrison
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
Ahmed El-Arabawy
 
Parse, scale to millions
Parse, scale to millions
Florent Vilmart
 
Introduction to Perl
Introduction to Perl
Sway Wang
 
Value protocols and codables
Value protocols and codables
Florent Vilmart
 
Advanced linux chapter ix-shell script
Advanced linux chapter ix-shell script
Eliezer Moraes
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)
Steven Francia
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話
dcubeio
 
Ansible ハンズオン on AWS - DevelopersIO 2017
Ansible ハンズオン on AWS - DevelopersIO 2017
Shuji Watanabe
 
JIP Pipeline System Introduction
JIP Pipeline System Introduction
thasso23
 
Logrotate sh
Logrotate sh
Ben Pope
 
Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout
source{d}
 
My life as a beekeeper
My life as a beekeeper
Pedro Figueiredo
 
File handling in c language
File handling in c language
Harish Gyanani
 
A Python Crash Course
A Python Crash Course
Alex-P. Natsios
 
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
geehwan
 
Fast and cost effective geospatial analysis pipeline with AWS lambda
Fast and cost effective geospatial analysis pipeline with AWS lambda
Mila Frerichs
 
2015 bioinformatics python_strings_wim_vancriekinge
2015 bioinformatics python_strings_wim_vancriekinge
Prof. Wim Van Criekinge
 
Why Python (for Statisticians)
Why Python (for Statisticians)
Matt Harrison
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
Ahmed El-Arabawy
 
Parse, scale to millions
Parse, scale to millions
Florent Vilmart
 
Introduction to Perl
Introduction to Perl
Sway Wang
 
Value protocols and codables
Value protocols and codables
Florent Vilmart
 
Advanced linux chapter ix-shell script
Advanced linux chapter ix-shell script
Eliezer Moraes
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)
Steven Francia
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話
dcubeio
 
Ansible ハンズオン on AWS - DevelopersIO 2017
Ansible ハンズオン on AWS - DevelopersIO 2017
Shuji Watanabe
 
JIP Pipeline System Introduction
JIP Pipeline System Introduction
thasso23
 
Logrotate sh
Logrotate sh
Ben Pope
 
Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout
source{d}
 
File handling in c language
File handling in c language
Harish Gyanani
 
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
Rotzy - Building an iPhone Photo Sharing App on Google App Engine
geehwan
 

Viewers also liked (20)

Defeating The Network Security Infrastructure V1.0
Defeating The Network Security Infrastructure V1.0
Philippe Bogaerts
 
class12_Networking2
class12_Networking2
T. J. Saotome
 
Unix Command Line Productivity Tips
Unix Command Line Productivity Tips
Keith Bennett
 
PHP Secure Programming
PHP Secure Programming
Balavignesh Kasinathan
 
Sed & awk the dynamic duo
Sed & awk the dynamic duo
Joshua Thijssen
 
Web Application Security: Introduction to common classes of security flaws an...
Web Application Security: Introduction to common classes of security flaws an...
Thoughtworks
 
Secure SHell
Secure SHell
Çağrı Çakır
 
Secure shell protocol
Secure shell protocol
Baspally Sai Anirudh
 
How to Setup A Pen test Lab and How to Play CTF
How to Setup A Pen test Lab and How to Play CTF
n|u - The Open Security Community
 
Web Application Security with PHP
Web Application Security with PHP
jikbal
 
Learning sed and awk
Learning sed and awk
Yogesh Sawant
 
Practical Example of grep command in unix
Practical Example of grep command in unix
Javin Paul
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Michael Coates
 
SSH - Secure Shell
SSH - Secure Shell
Peter R. Egli
 
Secure Shell(ssh)
Secure Shell(ssh)
Pina Parmar
 
SSH
SSH
Zach Dennis
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014
iimjobs and hirist
 
RHCE FINAL Questions and Answers
RHCE FINAL Questions and Answers
Radien software
 
Introduction to SSH
Introduction to SSH
Hemant Shah
 
Linux Systems Performance 2016
Linux Systems Performance 2016
Brendan Gregg
 
Defeating The Network Security Infrastructure V1.0
Defeating The Network Security Infrastructure V1.0
Philippe Bogaerts
 
Unix Command Line Productivity Tips
Unix Command Line Productivity Tips
Keith Bennett
 
Sed & awk the dynamic duo
Sed & awk the dynamic duo
Joshua Thijssen
 
Web Application Security: Introduction to common classes of security flaws an...
Web Application Security: Introduction to common classes of security flaws an...
Thoughtworks
 
Web Application Security with PHP
Web Application Security with PHP
jikbal
 
Learning sed and awk
Learning sed and awk
Yogesh Sawant
 
Practical Example of grep command in unix
Practical Example of grep command in unix
Javin Paul
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Michael Coates
 
Secure Shell(ssh)
Secure Shell(ssh)
Pina Parmar
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014
iimjobs and hirist
 
RHCE FINAL Questions and Answers
RHCE FINAL Questions and Answers
Radien software
 
Introduction to SSH
Introduction to SSH
Hemant Shah
 
Linux Systems Performance 2016
Linux Systems Performance 2016
Brendan Gregg
 
Ad

Similar to Practical unix utilities for text processing (20)

Treebeard's Unix Cheat Sheet
Treebeard's Unix Cheat Sheet
wensheng wei
 
Os lab manual
Os lab manual
Neelamani Samal
 
Unit 8 text processing tools
Unit 8 text processing tools
root_fibo
 
Ch05
Ch05
Mike Qaissaunee
 
Unix tips and tricks
Unix tips and tricks
Aleksandar Bilanovic
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1
Leandro Lima
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS
 
Linux
Linux
SINGH PROJECTS
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
 
113-1_Perl_2_Linux_commands_for_beginner.pdf
113-1_Perl_2_Linux_commands_for_beginner.pdf
ThoVyNguynVng
 
Unix / Linux Command Reference
Unix / Linux Command Reference
Sumankumar Panchal
 
Unix commands
Unix commands
selvamanisampath
 
Unix Cheat Sheet
Unix Cheat Sheet
Loiane Groner
 
Unix
Unix
akaash08
 
Unix
Unix
yarmuqam
 
Unix
Unix
Srinath Dhayalamoorthy
 
Unix Basics
Unix Basics
Dr.Ravi
 
Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
Karkha unix shell scritping
Karkha unix shell scritping
chockit88
 
Directories description
Directories description
Dr.M.Karthika parthasarathy
 
Treebeard's Unix Cheat Sheet
Treebeard's Unix Cheat Sheet
wensheng wei
 
Unit 8 text processing tools
Unit 8 text processing tools
root_fibo
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1
Leandro Lima
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
 
113-1_Perl_2_Linux_commands_for_beginner.pdf
113-1_Perl_2_Linux_commands_for_beginner.pdf
ThoVyNguynVng
 
Unix / Linux Command Reference
Unix / Linux Command Reference
Sumankumar Panchal
 
Unix Basics
Unix Basics
Dr.Ravi
 
Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
Karkha unix shell scritping
Karkha unix shell scritping
chockit88
 
Ad

More from Anton Arhipov (20)

JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdf
Anton Arhipov
 
Idiomatic kotlin
Idiomatic kotlin
Anton Arhipov
 
TechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервью
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCity
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCity
Anton Arhipov
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Anton Arhipov
 
GeeCON Prague 2018 - Kotlin DSL in under an hour
GeeCON Prague 2018 - Kotlin DSL in under an hour
Anton Arhipov
 
Build pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSL
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCity
Anton Arhipov
 
JavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainers
Anton Arhipov
 
GeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainers
Anton Arhipov
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JavaOne 2017 - TestContainers: integration testing without the hassle
JavaOne 2017 - TestContainers: integration testing without the hassle
Anton Arhipov
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JavaZone 2017 - The Hitchhiker’s guide to Java class reloading
JavaZone 2017 - The Hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentation
Anton Arhipov
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassle
Anton Arhipov
 
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
Anton Arhipov
 
JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdf
Anton Arhipov
 
TechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервью
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCity
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCity
Anton Arhipov
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Anton Arhipov
 
GeeCON Prague 2018 - Kotlin DSL in under an hour
GeeCON Prague 2018 - Kotlin DSL in under an hour
Anton Arhipov
 
Build pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSL
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCity
Anton Arhipov
 
JavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainers
Anton Arhipov
 
GeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainers
Anton Arhipov
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JavaOne 2017 - TestContainers: integration testing without the hassle
JavaOne 2017 - TestContainers: integration testing without the hassle
Anton Arhipov
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JavaZone 2017 - The Hitchhiker’s guide to Java class reloading
JavaZone 2017 - The Hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentation
Anton Arhipov
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassle
Anton Arhipov
 
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
Anton Arhipov
 

Recently uploaded (20)

Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 

Practical unix utilities for text processing