One line handies

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.

show your config:

   ruby -r yaml -r rbconfig -e'y Config::CONFIG'

-a

···

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.

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================

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 ":" :slight_smile:

David

--
David A. Black
dblack@wobblini.net

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.

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/81834

You'll find more with ruby one liners - Google Search

Kind regards

    robert

Hi --

> 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 ":" :slight_smile:

David

--
David A. Black
dblack@wobblini.net

···

On 8/8/05, David A. Black <dblack@wobblini.net> wrote:

On Tue, 9 Aug 2005, Lyndon Samson wrote:

cross platform sed-ness:

   harp:~ > ruby -r yaml -e 'y ENV[% PATH ].downcase.split(%r [:;] )'

···

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 ":" :slight_smile:

   ---
   - "."
   - "~/bin"
   - "~/shared/bin"
   - /home/ahoward/bin
   - /usr/local/sbin
   - /usr/sbin
   - /sbin
   - /data/bin
   - /usr/kerberos/bin
   - /usr/local/bin
   - /bin
   - /usr/bin
   - /usr/x11r6/bin
   - /dmsp/reference/bin
   - /usr/local/java/bin

:wink:

btw - this is the first use i've ever found for using the %<space> trick...

-a
--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================

oops

   harp:~ > ruby -r yaml -e 'y (ENV[% PATH ] || ENV[% path ]).downcase.split(%r [:;] )'

-a

···

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 ":" :slight_smile:

cross platform sed-ness:

harp:~ > ruby -r yaml -e 'y ENV[% PATH ].downcase.split(%r [:;] )'

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================

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 ":" :slight_smile:

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

Does this:

ruby -e 'puts ENV["PATH"].downcase.split(/[:;]/).sort'

not work on all platforms? Or are there quote/escaping issues?

DOS (cmd.exe) will need the double- and single-quotes swapped:

ruby -e "puts ENV['PATH'].downcase.split(/[:;]/).sort"

But... the colon will cause probs, because of windoze paths
like C:\blah\blah ...

Regards,

Bill

···

From: "David A. Black" <dblack@wobblini.net>

Hi,

At Tue, 9 Aug 2005 09:01:45 +0900,
David A. Black wrote in [ruby-talk:151306]:

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?

No. /home/foo/BIN and /home/foo/bin are different directories
on case-sensitive filesystems.

  ruby -e "puts ENV['PATH'].split(File::PATH_SEPARATOR).sort"

···

--
Nobu Nakada

Bill Kelly wrote:

From: "David A. Black" <dblack@wobblini.net>
> Does this:
>
> ruby -e 'puts ENV["PATH"].downcase.split(/[:;]/).sort'
>
> not work on all platforms? Or are there quote/escaping issues?

DOS (cmd.exe) will need the double- and single-quotes swapped:

ruby -e "puts ENV['PATH'].downcase.split(/[:;]/).sort"

Did you try it without swapping the quotes?

Unlike awk, mawk, and gawk, Ruby under DOS accepts single quotes as
argument wrappers. However, if the string contains |, <, or >, then
you had better use double quotes.

Hi!

···

At Tue, 9 Aug 2005 12:18:13 +0900, nobuyoshi nakada wrote:

At Tue, 9 Aug 2005 09:01:45 +0900,
David A. Black wrote in [ruby-talk:151306]:
> ruby -e 'puts ENV["PATH"].downcase.split(/[:;]/).sort'

No. /home/foo/BIN and /home/foo/bin are different directories on
case-sensitive filesystems.

  ruby -e "puts ENV['PATH'].split(File::PATH_SEPARATOR).sort"

Follows version that makes PATH case-insensitive. Works even if you
have several environment variables that match /^path$/ (possible under
Linux et. al.) their content is printed one after another).

ruby -e 'ENV.keys.grep(/^path$/i).each { |x| puts ENV.split(File::PATH_SEPARATOR)}'

Josef 'Jupp' SCHUGT
--
Terrorism is the systematic use of violence and brutality as a means of
gaining some political end. So the "War on Terrorism" is a failure if
it increases violence and brutality and even may be terrorism by itself
if some well-known incidents turn out not to be singular ones. :expressionless:

Bill Kelly wrote:
> DOS (cmd.exe) will need the double- and single-quotes swapped:
>
> ruby -e "puts ENV['PATH'].downcase.split(/[:;]/).sort"

Did you try it without swapping the quotes?

Unlike awk, mawk, and gawk, Ruby under DOS accepts single quotes as
argument wrappers. However, if the string contains |, <, or >, then
you had better use double quotes.

Whoa... ! Thanks. Makes me wonder if that always been true,
even back when the standard Ruby distribution for windows was
cygwin based? Or maybe I got so accustomed to

perl -e 'print "huzzah\n"'
Can't find string terminator "'" anywhere before EOF at -e line 1.

I never tried it on ruby!

Thanks,

Regards,

Bill

···

From: "William James" <w_a_x_man@yahoo.com>