LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I try to set a user defined variable but it understands a command (http://www.linuxquestions.org/questions/linux-newbie-8/i-try-to-set-a-user-defined-variable-but-it-understands-a-command-694677/)

albinworld 01-03-2009 09:41 AM

I try to set a user defined variable but it understands a command
 
I try to set a variable with the result of a command but It doesn´t works.

When I write the name of the variable in these ways:
hip = `cat something.txt`
echo "The content is '$hip'"

or
hip = $(cat something.txt)
echo "The content is '$hip'"

the shell says "hip command not found" and points to the first line

and when I write the name of the variable after in these ways:
set hip = `cat something.txt`
echo "The content is '$hip'"

or
set hip = $(cat something.txt)
echo "The content is '$hip'"

the shell shows:
The content is ''

what's wrong?

Thanks in advance.

pwc101 01-03-2009 09:52 AM

Assuming bash, there's no space between the variable name and what you're assigning it:
Code:

somevar = "wrong"
somevar="right"


albinworld 01-03-2009 09:58 AM

Ouch!
Perfect
Thanks a lot.

pwc101 01-03-2009 02:42 PM

No problem :)


All times are GMT -5. The time now is 02:44 PM.