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
57
Practical unix utilities for text processing
Anton Arhipov
October 01, 2010
Tweet
Share
More Decks by Anton Arhipov
See All by Anton Arhipov
Everybody is a Marketer
antonarhipov
0
58
Idiomatic Kotlin, v2023.05
antonarhipov
0
88
Kotlin DSL in under an hour, DevoxxUK 2023
antonarhipov
0
78
Idiomatic Kotlin - KotlinConf Global, Vietnam
antonarhipov
1
69
Kotlin_for_server-side_application_development.pdf
antonarhipov
0
72
Idiomatic Kotlin - IntelliJ IDEA Conf 2022
antonarhipov
0
410
The Lesser-Known Kotlin Features
antonarhipov
0
460
JavaZone 2022 - Building Kotlin DSL
antonarhipov
1
160
SpringIO 2022 - Spring extensions for Kotlin
antonarhipov
0
79
Other Decks in Technology
See All in Technology
ビジネスロジックを「型」で表現するOOPのための関数型DDD / Functional And Type-Safe DDD for OOP
yuitosato
29
11k
Evolutionary Optimization of Model Merging Recipes
fuyu_quant0
3
510
Skaffoldを用いたGKEアプリケーションの CD(Continuous Development)
kojake_300
1
230
HoneycombとOpenTelemetryでオブザーバビリティに入門してみる
sumiren
2
140
オブジェクト指向宗教史
tanakahisateru
13
11k
あらゆる商品を扱う商品データベースを再設計した話 / product db re-architecture
rince
7
3.2k
継続的テストモデルを実現するためにスリーアミーゴスを用いた10Xでのシフトレフトの事例
nihonbuson
2
110
Azureコストは水道代/The_47th_Tokyo_Jazug
aeonpeople
3
350
暗黙知を集積するプラットフォーム : 「健常者エミュレータ事例集」の取り組み
sora32127
1
160
Cloud Deploy と仲良くなりたい
phaya72
1
100
Tohoku.Tech #1 「EC-CUBE/AWSの構築をChatGPTに相談してみました」by テンダ
jun2882
0
140
KubeCon EU: Unlocking new Platform Experiences with Open Interfaces
salaboy
1
360
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
10
4.5k
How to name files
jennybc
62
92k
Optimizing for Happiness
mojombo
369
69k
Making Projects Easy
brettharned
106
5.4k
How to Ace a Technical Interview
jacobian
272
22k
Building Your Own Lightsaber
phodgson
97
5.6k
Navigating Team Friction
lara
177
13k
Being A Developer After 40
akosma
56
580k
Optimising Largest Contentful Paint
csswizardry
7
2.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
185
15k
No one is an island. Learnings from fostering a developers community.
thoeni
14
2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
6
950
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