Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I echo $CATALINA_HOME I get a blank line, but when I ls $CATALINA_HOME I correctly get a listing of the directory. Why can't I echo it? I am running Ubuntu 11.04.

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

Because ls $CATALINA_HOME is expanding $CATALINA_HOME to the empty string and accordingly simply doing ls (or ls . to be pedantic). Either you're in the correct directory already or you're not getting what you think you are.

share|improve this answer
1  
Ah! Of course. Turns out I am not getting what I thought I was. I have a regular Tomcat setup - any idea why these environment variables aren't being set? Or maybe they are just set for a tomcat user/group? Because it seems to be working correctly, I was just curious. –  skaz Jul 1 '11 at 2:12
    
I would guess they're set right by whatever starts up Tomcat, but not for anything else. But I don't know Tomcat so it's just a guess. –  geekosaur Jul 1 '11 at 2:19
    
Great! Thanks! –  skaz Jul 1 '11 at 2:20
add comment

There is no environment variable $CATALINA_HOME unless you defined it beforehand. You can see that the output of ls will always display the current directory (that is not necessarily your home directory!) if invoked with an empty or undefinded variable:

 ls $BLABLABLA

The current user's home directory is stored in $HOME:

echo $HOME

The current user name is stored in $USER:

echo $USER

Only invoking ls with $HOME will always list the contents of the current user's home directory.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.