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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ryo Shibayama
February 27, 2015
Technology
51
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
470
採用は全員で | Chuo TECH #1
serima
4
1.5k
高専 5 年時に 7 泊 8 日の合宿型ビジコンに参加したら人生が変わった
serima
0
480
カジュアル面談を通して “自社”のことを知る
serima
0
300
倒れても進捗 / Progress even if I fall
serima
1
920
CircleCI 導入への入門 / Introduction to CircleCI
serima
0
160
GameWithを支えるインフラ基盤 - スケールイン・アウト戦略編 / GameWith infrastructure - Scale in and out strategy
serima
0
110
エンジニア採用と PHP / Engineer Recruitment and PHP
serima
0
140
できることから始める OSS Contribution / Start OSS Contribution With What You Know
serima
1
300
Other Decks in Technology
See All in Technology
In-Context Learning再入門。ICLの勾配降下的解釈の研究動向を追ってみる。
dai08srhg
1
720
Kiro Crew の Bot (続く役目を任せる窓口) | 目指せ Kiro マスター 12
inariku
PRO
2
310
Technical Project Manager の役割とやりがい、少しだけ AI
yoshiiryo1
0
600
新卒エンジニア、 介護士になる
ryu1013
1
690
属人化したISMS運用をGitHubとAIで仕組み化した1年間の記録
sioncojp
0
530
re:Invent2026 事前勉強会 歴史と愉しみ方10分LT編
toshi_atsumi
0
160
詳解 never 型 - ボトム型の性質を深掘り
nealle
0
160
bpf_arenaとstruct_opsを使うのが難しかった話
masu_mi
0
210
AWSを利用する上で知っておきたい名前解決の話 2026
nagisa53
5
3.2k
複雑な業務システムを高速でつくるため、チーム全員をつくれる人へ
ayakurabuchi
0
140
cdkd (CDK Direct)
gotok365
4
270
HQ駆動開発で最高のAI-Contextを作ろう
sansantech
PRO
1
110
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
460
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
The Curious Case for Waylosing
cassininazir
1
610
How to Think Like a Performance Engineer
csswizardry
28
2.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
320
We Are The Robots
honzajavorek
0
440
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.3k
Scaling GitHub
holman
464
140k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
Facilitating Awesome Meetings
lara
57
7.2k
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