Why can I echo an environment variable but not use it to cd or ls?

150 views Asked by At

How come I can echo the $RUBYPATH variable:

[grant@rails-box app]$ echo $RUBYPATH
/opt/rubies/ruby-2.3.0

And ls that directory:

[grant@rails-box app]$ ls /opt/rubies/ruby-2.3.0
bin  include  lib  share

But I can't ls using the variable?

[grant@rails-box app]$ ls $RUBYPATH
: No such file or directoryes/ruby-2.3.0
1

There are 1 answers

0
James K. Lowden On BEST ANSWER

Bishop is right: try

$ echo $RUBYPATH | cat -v # or hexdump -C