Skip to content

Latest commit

 

History

History
21 lines (8 loc) · 403 Bytes

ruby_interactive.md

File metadata and controls

21 lines (8 loc) · 403 Bytes

Ruby's -e, -n and -p switches

ps ax |ruby -ne 'puts $_.split.first if $_ =~ /top/'

echo "eats, shoots, and leaves" | ruby -pe '$_.gsub!("e", "a")'^

echo "foo\nbar\nbaz" | ruby -ne 'BEGIN { i = 1 }; puts "#{i} #{$_}"; i+= 1'

sudo docker exec -it $(sudo docker ps | ruby -ne 'puts $_.split.first if $_ =~ /resque/') bash

source: https://robm.me.uk/ruby/2013/11/20/ruby-enp.html