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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
890
CircleCI 導入への入門 / Introduction to CircleCI
serima
0
150
GameWithを支えるインフラ基盤 - スケールイン・アウト戦略編 / GameWith infrastructure - Scale in and out strategy
serima
0
100
エンジニア採用と 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
映像変換サーバーなしで端末内でHLSを生成してライブ配信
hikarusato
0
130
積み重なった技術負債への挑戦 〜初手としての全社ゴト化〜
techtekt
PRO
0
1.4k
ユーザー価値を届け続けるためにウォンテッドリーが大切にしている文化
kotaminato
0
180
2026_devsumi_ozono.pdf
o3
3
540
Genieを崇めよ
kameitomohiro
0
170
事業課題から技術的負債に向き合う
sansantech
PRO
2
2k
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
5
540
アクセスキーこわい やめかたと漏らさない工夫
sassssan68
1
530
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
12k
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
30
17k
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
3
1k
ソフトウェアDNAとクラウドエージェントのススメ
cloudace
0
120
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
GitHub's CSS Performance
jonrohan
1033
470k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
A Tale of Four Properties
chriscoyier
163
24k
Designing for Performance
lara
611
70k
Practical Orchestrator
shlominoach
192
12k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Marketing to machines
jonoalderson
1
5.8k
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