LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 08: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, 08: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, 08: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, 01: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



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 07:18 PM
tcsh set/read variable command? johnpaulodonnell Linux - Newbie 2 08-22-2007 09:26 AM
How to set PATH variable for command tracert? princegbenga Linux - Software 2 06-14-2007 07:48 AM
Replace variable with user defined variable ce124 Programming 10 04-13-2007 09:29 AM
set the ouput of a command to a variable true_atlantis Linux - Newbie 2 03-23-2006 03:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:28 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
Open Source Consulting | Domain Registration