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
Ruby One-Liners
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
bjelli
March 23, 2012
Programming
340
1
Share
Ruby One-Liners
A lightning talk at Salzburg Barcamp "The Next Web" in March 2012.
bjelli
March 23, 2012
More Decks by bjelli
See All by bjelli
Intro to Web- and Mobile-Developement
bjelli
0
320
Railsgirls: Where did my HTML and CSS go
bjelli
0
590
Berufe im World Wide Web
bjelli
0
260
Javascript Closures
bjelli
3
900
Teach (all the) Rails
bjelli
0
450
Other Decks in Programming
See All in Programming
Nuxt Server Components
wattanx
0
250
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
210
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
560
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
2
150
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
170
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
250
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
110
Don't Prompt Harder, Structure Better
kitasuke
0
380
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.3k
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
160
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
550
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
830
Featured
See All Featured
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
88
RailsConf 2023
tenderlove
30
1.4k
HDC tutorial
michielstock
1
610
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
170
[SF Ruby Conf 2025] Rails X
palkan
2
930
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
470
How to build a perfect <img>
jonoalderson
1
5.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Transcript
Ruby One-Liner
mit -e Programmcode angeben ruby -e ' puts "hello" '
ruby -e 'puts "Hello"' mit -e Programm angeben
ruby -e 'puts 24 * 60 * 60 ' mein
Taschenrechner
ruby -p -e '' langer.txt -p print-schleife über datei
ruby -p -e 'puts' langer.txt leerzeile nach jeder zeile
ruby -p -e 'puts $_.length' langer.txt $_ enthält die Zeile
ruby -p -e 'puts "#{$.}.Zeile hat länge #{$_.length} " '
langer.txt $. enthält die Zeilennummer
Korrektur • es geht nicht um Zeilen • sondern um
"Records" • default: Record-Separator ist "\n" • deswegen wird zeilenweise gelesen • Der Separator ist in der Variable $/
ruby -00 -p -e 'puts "#{$.}.Absatz hat länge #{$_.length} "
' l.txt -00 verwende doppelten separator Absatz statt Zeile
ruby -p -e 'puts "."' index.html -n schleif, nicht ausgeben
ruby -n -e 'puts if /Schokolade/' index.html Finden grep
ruby -p -e 'gsub(/Game/, "Web")' index.html Ersetzen
ruby -i.bak -p -e 'gsub(/Game/, "Web")' index.html Ersetzen in der
Datei neu in index.html, alt in index.html.bak
ruby -i.bak -p -e 'gsub(/Game/, "Web")' *.html Ersetzen in vielen
Dateien
ruby command line switches + ruby one-liners + unix |
Learn More