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
160
Rubyc
Rubyc helps you at the command line
Martin Chabot
September 20, 2012
Tweet
Share
Other Decks in Programming
See All in Programming
AI時代のUIはどこへ行く?
yusukebe
18
8.9k
Introducing ReActionView: A new ActionView-compatible ERB Engine @ Rails World 2025, Amsterdam
marcoroth
0
690
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
22
5.8k
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
220
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
440
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
300
Tool Catalog Agent for Bedrock AgentCore Gateway
licux
6
2.5k
Laravel Boost 超入門
fire_arlo
3
220
私の後悔をAWS DMSで解決した話
hiramax
4
210
「待たせ上手」なスケルトンスクリーン、 そのUXの裏側
teamlab
PRO
0
530
print("Hello, World")
eddie
2
530
Namespace and Its Future
tagomoris
6
700
Featured
See All Featured
Writing Fast Ruby
sferik
628
62k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Producing Creativity
orderedlist
PRO
347
40k
GraphQLの誤解/rethinking-graphql
sonatard
72
11k
The Cult of Friendly URLs
andyhume
79
6.6k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Code Review Best Practice
trishagee
70
19k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.9k
GitHub's CSS Performance
jonrohan
1032
460k
For a Future-Friendly Web
brad_frost
180
9.9k
Facilitating Awesome Meetings
lara
55
6.5k
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