From: "David A. Black" Date: 2005-08-09T09:01:45+09:00 Subject: Re: One line handies Hi -- On Tue, 9 Aug 2005, Ara.T.Howard wrote: > On Tue, 9 Aug 2005, Ara.T.Howard wrote: > >> On Tue, 9 Aug 2005, David A. Black wrote: >> >>> Hi -- >>> >>> On Tue, 9 Aug 2005, Lyndon Samson wrote: >>> >>>> Ruby is such a sweet language that you can achieve alot with little code >>>> >>>> I'd like to see what 'one-liners' others have come up with. >>>> >>>> here's one I find usefull. >>>> >>>> ruby -e 'puts ENV["path"].downcase.split(";").sort' >>>> >>>> handy for windows but *nix ppl would probably use sed. >>> >>> Not necessarily, but we would use PATH and ":" :-) >> >> cross platform sed-ness: >> >> harp:~ > ruby -r yaml -e 'y ENV[% PATH ].downcase.split(%r [:;] )' > > oops > > harp:~ > ruby -r yaml -e 'y (ENV[% PATH ] || ENV[% path > ]).downcase.split(%r [:;] )' I'm not sure I get why you'd need all this (YAML, the space trick, the two cases). Does this: ruby -e 'puts ENV["PATH"].downcase.split(/[:;]/).sort' not work on all platforms? Or are there quote/escaping issues? David -- David A. Black dblack@wobblini.net