|
Contact Us |
|||
Ruby One-LinersJune, 2011
ruby -e 'p (1..10).map {|n| n * n * n } '
ruby -rdate -e 'p DateTime.now.cweek' # gives the calendar week # for the current year
## separate a list
ruby -e 'p [22, 333, 498, 55, 11,17, 99].partition { |n| n>60|'
## sum the list
ruby -e 'p (1..45).inject { |sum,n| sum + n}'
## edit in place
ruby -pi.bak -e "gsub(/1.5/,'1.6')" v*.txt
"With a PC, I always felt limited by the software available. On Unix, I am limited only by my knowledge." |
||||
|
Copyright 1998-2012 Celebrazio.net