Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Practical unix utilities for text processing
Search
Anton Arhipov
October 01, 2010
Technology
0
65
Practical unix utilities for text processing
Anton Arhipov
October 01, 2010
Tweet
Share
More Decks by Anton Arhipov
See All by Anton Arhipov
Strengthening Immutability in Kotlin. A Glimpse into Valhalla
antonarhipov
2
24
Kotlin—the New and Noteworthy in 2.2
antonarhipov
1
6
Levels of AI-assisted programming
antonarhipov
0
62
Devoxx France 2024. Kotlin - the new and noteworthy
antonarhipov
2
44
Harnessing the power of AI in IntelliJ IDEA
antonarhipov
1
180
VirtualJUG: Kotlin 2.0 and beyond
antonarhipov
1
120
Kotlin 2.1: Language Updates
antonarhipov
3
150
Devoxx Belgium 2024 - Kotlin 2.0 and beyond
antonarhipov
2
170
Data Analysis with Kotlin Notebook, DataFrame, and Kandy
antonarhipov
1
90
Other Decks in Technology
See All in Technology
AgentCon Accra: Ctrl + Alt + Assist: AI Agents Edition
bethany
0
100
アイテムレビュー機能導入からの学びと改善
zozotech
PRO
0
150
Geospatialの世界最前線を探る [2025年版]
dayjournal
1
220
プレーリーカードを活用しよう❗❗デジタル名刺交換からはじまるイベント会場交流のススメ
tsukaman
0
150
業務効率化をさらに加速させる、ノーコードツールとStep Functionsのハイブリッド化
smt7174
2
140
GoでもGUIアプリを作りたい!
kworkdev
PRO
0
140
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.2k
防災デジタル分野での官民共創の取り組み (2)DIT/CCとD-CERTについて
ditccsugii
0
290
能登半島地震で見えた災害対応の課題と組織変革の重要性
ditccsugii
0
750
Simplifying Cloud Native app testing across environments with Dapr and Microcks
salaboy
0
150
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
310
AWSでAgentic AIを開発するための前提知識の整理
nasuvitz
2
150
Featured
See All Featured
A Tale of Four Properties
chriscoyier
161
23k
Bash Introduction
62gerente
615
210k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
RailsConf 2023
tenderlove
30
1.2k
Docker and Python
trallard
46
3.6k
Git: the NoSQL Database
bkeepers
PRO
431
66k
It's Worth the Effort
3n
187
28k
Reflections from 52 weeks, 52 projects
jeffersonlam
353
21k
Making Projects Easy
brettharned
120
6.4k
Speed Design
sergeychernyshev
32
1.2k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Side Projects
sachag
455
43k
Transcript
grep | sed | awk | xargs | etc
None
sed vim awk ls
cat tac head tail split wc sum sort uniq kill cut paste join tr dir mv du echo test expr tee grep
DB Mega App Files Log
GNU Coreutils http://www.gnu.org/software/coreutils/ The takeaway
command: man > info coreutils
List of files: ls –l ls –1
ls –latr find . –name *.txt
Seek for a string in a file: grep
“cat” file.txt grep –v “dog” file.txt grep –i “PaTtErN” file.txt egrep “cat|dog” file.txt zgrep “cat” file.txt.gz
for file in `find . –name *tmp` do
rm $file done find . –name *tmp | xargs rm Do something with each file:
find + grep find . -‐name '*txt' -‐exec
grep -‐l aaa {} \; find . -‐name '*txt' | xargs grep -‐l aaa
ls cat tac head tail
split wc sum sort uniq kill cut paste join tr dir mv du echo test expr tee grep
None
None
None
None
None
None
sed awk
s for substitution sed ‘s/cat/dog/’ #
cat -‐> dog sed ‘s/\(a\)\(b\)/\2\1/’ # ab -‐> ba
p for printing sed –n ‘/dog/p’
# print lines that match ‘dog’ sed –n ‘/start/,/end/p’ # print range
d to delete sed ‘/dog/d’ # delete
lines that match ‘dog’ sed ‘1,/pattern/d’ # delete range
| and –e for invocation sed ‘s/a/A/’ |
sed ‘s/b/B/’ # sed –e ‘s/a/A/’ –e ‘s/b/B/’ #
{ .. } to group the commands sed
‘/pattern/ { s/p/P/ s/e/E/ }’ #pattern -‐> PattErn
r to read a file sed ‘/include/ r
file.txt’ # insert file.txt after include w to write to a file sed ‘/pattern/ w file.txt’ # write matched lines to a file
None
aaa bbb ccc aaa bbb zzz awk
'/zzz/' 1.txt grep zzz 1.txt aaa bbb zzz
awk 'BEGIN
{<initializations>} <pattern 1> {<actions>} <pattern 2> {<actions>} ... END {<final actions>}'
awk 'BEGIN {a=0, b=0}
/aaa/ {a++} /bbb/ {b++} END {printf “%d\t%d”,a,b}'
awk '{arr[$2]+=$1} END {
for (id in arr) printf "%s\t%d\t\n",id,arr[id]}'
@antonarhipov