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
62
Practical unix utilities for text processing
Anton Arhipov
October 01, 2010
Tweet
Share
More Decks by Anton Arhipov
See All by Anton Arhipov
Devoxx Belgium 2024 - Kotlin 2.0 and beyond
antonarhipov
1
69
Data Analysis with Kotlin Notebook, DataFrame, and Kandy
antonarhipov
1
12
Kotlin 2.0 and Beyond
antonarhipov
2
160
Kotlin Standard Library Gems
antonarhipov
2
440
Ktor Workshop
antonarhipov
1
75
Everybody is a Marketer
antonarhipov
0
110
Idiomatic Kotlin, v2023.05
antonarhipov
2
130
Kotlin DSL in under an hour, DevoxxUK 2023
antonarhipov
2
120
Idiomatic Kotlin - KotlinConf Global, Vietnam
antonarhipov
1
97
Other Decks in Technology
See All in Technology
【shownet.conf_】コンピューティング資源を統合した分散コンテナ基盤の進化
shownet
PRO
0
420
【インフラエンジニアbooks】30分でわかる「AWS継続的セキュリティ実践ガイド」
hssh2_bin
4
1.7k
LINEヤフー新卒採用 コーディングテスト解説 実装問題編
lycorp_recruit_jp
1
12k
Oracle GoldenGate 23ai 導入Tips
oracle4engineer
PRO
1
280
UE5の雑多なテク
ryuichikawano
0
410
Kubernetes Meetup Tokyo #67 - KEP-3619: Fine-grained SupplementalGroups Control / k8sjp67-kep-3619
everpeace
0
130
エンジニア向け会社紹介資料
caddi_eng
14
270k
プロダクト価値を考えるための情報透明化とチーム文化づくり
nyo_taro
1
140
電子辞書にステータスバーを実装する
puhitaku
0
110
LeSSはスクラムではない!?LeSSにおけるスクラムマスターの振る舞い方とは / Scrum Master Behavior in LeSS
toma_sm
0
210
【完全版】Dify - LINE Bot連携 考え方と実用テクニック
uezo
2
410
テストを楽に書きたい
tomorrowkey
1
180
Featured
See All Featured
Six Lessons from altMBA
skipperchong
26
3.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.3k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.9k
Ruby is Unlike a Banana
tanoku
96
11k
Thoughts on Productivity
jonyablonski
67
4.2k
Facilitating Awesome Meetings
lara
49
6k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
The Invisible Side of Design
smashingmag
297
50k
Designing the Hi-DPI Web
ddemaree
280
34k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
Testing 201, or: Great Expectations
jmmastey
38
7k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
249
21k
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