LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 01-03-2009, 09:41 AM   #1
albinworld
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Rep: Reputation: 0
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.
 
Old 01-03-2009, 09:52 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Assuming bash, there's no space between the variable name and what you're assigning it:
Code:
somevar = "wrong"
somevar="right"
 
Old 01-03-2009, 09:58 AM   #3
albinworld
LQ Newbie
 
Registered: Jan 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Ouch!
Perfect
Thanks a lot.
 
Old 01-03-2009, 02:42 PM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
No problem
 
  


Reply

Tags
bash


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows batch script: SET command as variable Dr_Death_UAE Programming 10 09-09-2007 08:18 PM
tcsh set/read variable command? johnpaulodonnell Linux - Newbie 2 08-22-2007 10:26 AM
How to set PATH variable for command tracert? princegbenga Linux - Software 2 06-14-2007 08:48 AM
Replace variable with user defined variable ce124 Programming 10 04-13-2007 10:29 AM
set the ouput of a command to a variable true_atlantis Linux - Newbie 2 03-23-2006 04:30 PM


All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration