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
知って得するかもしれないテキスト処理コマンドの話 / A story about text ...
Search
Ryo Shibayama
February 27, 2015
Technology
47
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
知って得するかもしれないテキスト処理コマンドの話 / A story about text processing commands that you might get to know
Ryo Shibayama
February 27, 2015
More Decks by Ryo Shibayama
See All by Ryo Shibayama
技術広報の集い #3 Lightning Talk - LayerX
serima
0
460
採用は全員で | Chuo TECH #1
serima
4
1.5k
高専 5 年時に 7 泊 8 日の合宿型ビジコンに参加したら人生が変わった
serima
0
470
カジュアル面談を通して “自社”のことを知る
serima
0
290
倒れても進捗 / Progress even if I fall
serima
1
910
CircleCI 導入への入門 / Introduction to CircleCI
serima
0
150
GameWithを支えるインフラ基盤 - スケールイン・アウト戦略編 / GameWith infrastructure - Scale in and out strategy
serima
0
110
エンジニア採用と PHP / Engineer Recruitment and PHP
serima
0
130
できることから始める OSS Contribution / Start OSS Contribution With What You Know
serima
1
290
Other Decks in Technology
See All in Technology
WasmをRustにする
sansantech
PRO
0
260
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
940
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
160
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
120
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
880
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
170
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3.1k
How to Design Configuration for Rails Applications
willnet
1
820
Classmethod Company Deck
satoshi7
1
710
Running Kotlin + Quarkus with Lambda
nealle
1
3.8k
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Site-Speed That Sticks
csswizardry
13
1.6k
Ruling the World: When Life Gets Gamed
codingconduct
0
400
Automating Front-end Workflow
addyosmani
1369
210k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The SEO identity crisis: Don't let AI make you average
varn
0
590
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Side Projects
sachag
456
43k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Transcript
知って得するかもしれない テキスト処理理コマンドのお話 @serima
⾃自⼰己紹介 | PHP歴 今年年で 8 年年⽬目 初めての PHP 勉強会への参加
今後も頑張りたい
ビッグデータと僕 ソーシャルゲームの運⽤用 データ命 アクセスログ、課⾦金金ログ、戦闘ロ グ、カード取得ログ…
データのダンプ mysqldump scp
TreasureData あらゆるログを TreasureData に集 約 これで取り出しやすくはなった
ディレクターさん 「せりまさん、こんなデータ取って ください」 「おk」
巨⼤大なデータ いざ取り出してみると、数⼗十万〜~数 百万⾏行行になることはザラ この規模のデータを Excel で開くと 死亡 なので、ある程度度サマリする必要が
でてきます
サマリするためのスクリプト データ規模が⼤大きくなってくると PHP つかって書くと超遅い
それ… UNIX コマンドでできるよ
よく使うコマンド cat, sort, uniq, wc, grep, awk, diff, cut,
sed
join ふたつのファイルの共通 key で連結 ふたつのファイルは結合するフィー ルドで sort しておく必要がある
join の使⽤用例例 a.txt には ユーザ ID, 課⾦金金額, 戦闘⼒力力 の順で⼊入ってる
b.txt には ユーザ ID, ユーザ名 の順で⼊入ってる join -‐‑‒a1 -‐‑‒eʼ’-‐‑‒ʼ’ -‐‑‒oʼ’0 1.2 1.3 2.2ʼ’ <(sort a.txt) <(sort b.txt)
プロセス置換 | 知ってる? <(sort a.txt) bash や zsh の機能
sort 済みのテンポラリファイルを作 る必要がなくなる
プロセス置換 | 知らない これを知るまで cat a.txt | sort >
a_̲sorted.txt 無駄なファイル量量産してた
集合演算っぽいこと A に含まれるが、B に含まれない ID を出したい 1 2
3 1 3 2 A B ほしい結果
差集合 diff と awk でできるよ diff <(sort A) <(sort B)
| awk ʻ‘/^</{print $2}ʼ’
他の集合演算 和集合 A∪B cat A B | sort |
uniq 積集合 A∩B cat A B | sort | uniq -‐‑‒d join A B
join コマンド join コマンドはとても便便利利だけど、 ふたつの引数しかとることができな い
tsv や csv に query 投げたい あるんです q -‐‑‒
Text as Data https://github.com/harelba/q q って!ググラビリティ低すぎ
試しに使ってみる % seq 1 1000 | q "select avg(c1),sum(c1) from
-‐‑‒" 500.5 500500 c1というのが、カラムの1番⽬目という意味なので、 avg(c1)で、1〜~1000の総和の平均 sum(c1)で、1〜~1000の総和 がちゃんと出てますね
GROUP BY も使える % cat test.txt Mike
10 John 1 Bob 8 Mary 19 Bob 15 Bob 20 Mike 2 % q "select c1, count(*), sum(c2) from test.txt group by c1" Bob 3 43 John 1 1 Mary 1 19 Mike 2 12
JOIN も使える % cat test1.txt a1234 aa1
b1234 aa2 c1234 aa3 d1234 aa3 ! % cat test2.txt 1 a1234 bb1 2 a1234 bb2 3 b1234 cc1 4 c1234 dd3 5 e1234 NULL ! % q "select * from test1.txt as a left join test2.txt as b on a.c1 = b.c2" a1234 aa1 1 a1234 bb1 a1234 aa1 2 a1234 bb2 b1234 aa2 3 b1234 cc1 c1234 aa3 4 c1234 dd3 d1234 aa3
ご清聴ありがとうございました ブログにこの事書いてるのでご興味 あればどうぞ http://serima.co/blog