LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 03-10-2006, 09:22 PM   #1
Akhran
Member
 
Registered: Aug 2005
Distribution: Debian 'lenny'
Posts: 208

Rep: Reputation: 30
Variables within single quotes are not evaluated?


$echo 'HOME variable has value $HOME'
HOME variable has value $HOME

$echo "HOME variable has value $HOME"
HOME variable has value /home/john

However, I notice that ~/.bashrc, I have lines that go

export LS_OPTIONS='--color=auto'

alias ls='ls $LS_OPTIONS'

and the ls does expand out correctly to ls --color=auto in the commandline. I thought the single quotes are suppose to keep the content literally? aka ls should expand out to be ls $LS_OPTIONS on the commandline?

Would alias ls="ls $LS_OPTIONS" be handled 'more' correctly?


Thanks !
*confused*
 
Old 03-10-2006, 09:32 PM   #2
PenguinPwrdBox
Member
 
Registered: Oct 2003
Posts: 568

Rep: Reputation: 30
It varies, but in most languages, including shell, variable interpolation will only be performed when used within double quotes. In the export statement (again, dealing with shell) - you are not using a variable, you assigning a constant value to one.

You could not use quotes in all of those examples, the only exception being that you would have to escape the second "=" in the LS_OPTIONS export statement. You'd still get the desired results.
 
  


Reply


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
Problems with quotes and double quotes Andruha Slackware 6 01-02-2010 05:44 PM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 12:41 PM
replacing single quotes in file names adenardo Linux - General 2 05-27-2005 12:29 PM
RPM spec file install rule how its evaluated? cranium2004 Programming 2 03-11-2005 03:03 AM
In BASH shell, what is the difference in usage between single and double quotes? davidas Linux - Newbie 2 04-05-2004 04:00 AM


All times are GMT -5. The time now is 01:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration