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
Rubyc
Search
Martin Chabot
September 20, 2012
Programming
3
150
Rubyc
Rubyc helps you at the command line
Martin Chabot
September 20, 2012
Tweet
Share
Other Decks in Programming
See All in Programming
try! Swift Tokyo 初参加報告LT
hinakko2
0
180
Folding Cheat Sheet #2
philipschwarz
PRO
0
110
Open Source Swift Workshop - Foundation and first party libraries
ikesyo
0
1.1k
どうしてこうなった命名集 ~🔥編~ / OOC 2024 LT
pictiny
5
3.9k
OpenAPI を守るのは難しい
ohmori_yusuke
2
770
DDDはなぜ難しいのか / 良いコードの定義と設計能力の壁
pospome
28
10k
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
1.1k
本格ローグライク制作にEbitengineを選んでみた
nagainaganawa
0
290
甘い香りに誘われてVanilla Extractを1年間運用してみた
miyahkun
1
110
オブジェクト指向のリ・オリエンテーション~歴史を振り返り、AI時代に向きなおる~
hanyudaeiiti
9
5.6k
デザインシステムで Tailwind CSSとCSS in JSに分散投資をしたら良かった話
fsubal
18
4.8k
CircleCIを活用して AWSへの継続的デリバリーを 実践する
coconala_engineer
1
230
Featured
See All Featured
Music & Morning Musume
bryan
40
5.6k
A designer walks into a library…
pauljervisheath
199
23k
How to Ace a Technical Interview
jacobian
272
22k
Scaling GitHub
holman
457
140k
Stop Working from a Prison Cell
hatefulcrawdad
265
19k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
What the flash - Photography Introduction
edds
64
11k
In The Pink: A Labor of Love
frogandcode
137
21k
Product Roadmaps are Hard
iamctodd
43
9.7k
Happy Clients
brianwarren
91
6.4k
Why You Should Never Use an ORM
jnunemaker
PRO
50
8.6k
Six Lessons from altMBA
skipperchong
19
3k
Transcript
Rubyc Martin Chabot Thursday, 20 September, 12
File Processing Thursday, 20 September, 12
Unix Tools • grep • find • xargs • sed
• awk • ... Thursday, 20 September, 12
Do you need to look at documentation to use sed
& awk? Thursday, 20 September, 12
If no, this presentation is not for you! Thursday, 20
September, 12
Otherwise, Why don’t you use Ruby? Thursday, 20 September, 12
ruby -n -e Thursday, 20 September, 12
Ruby’s man pages Thursday, 20 September, 12
Example cat my_file | ruby -n -e "print if /wombat/"
Thursday, 20 September, 12
ruby -p -e Thursday, 20 September, 12
Ruby’s Man Pages Thursday, 20 September, 12
ruby -r Thursday, 20 September, 12
Ruby’s man Pages Thursday, 20 September, 12
Ruby 1.8 • Can only have one -r option •
You cannot use it with rubygems Thursday, 20 September, 12
Thursday, 20 September, 12
Ruby 1.9 • Can only have many -r options •
eg: -r rubygems -r csv Thursday, 20 September, 12
Rubyc Gem • Supports Enumerable methods: map, select etc. •
Iterates on each line • Sets the ‘line’ variable and its ‘l’ alias • Sets the ‘lnum’ and the ‘index’ variable Thursday, 20 September, 12
Example Thursday, 20 September, 12
Thursday, 20 September, 12
Rubyc commands Thursday, 20 September, 12
Use Case I Colorize stderr Thursday, 20 September, 12
The shell way rake 2> >(while read line;do echo -e
"\033[31m$line \033[0m";done) Thursday, 20 September, 12
The Ruby 1.9 Way rake 2> >(ruby -r colorize -p
-e ‘$_ = $_.red’) Thursday, 20 September, 12
rake 2> >(rubyc map -r colorize ‘l.red’) The Rubyc Way
Thursday, 20 September, 12
Use Case II Extract the number of insertions per db
table in a Rails log file Thursday, 20 September, 12
The Shell Way To lazy to work on it !
Thursday, 20 September, 12
The Ruby Way To lazy too ! Thursday, 20 September,
12
The Rubyc Way Thursday, 20 September, 12
Conclusion • If you feel confortable with ruby’s -n -p
options continue using it. • If your like me, give Rubyc a chance. • Give me some feedback Thursday, 20 September, 12