LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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
 
Thread Tools
Old 03-10-2006, 09:22 PM   #1
Akhran
Member
 
Registered: Aug 2005
Distribution: Debian 'lenny'
Posts: 202
Thanked: 0
Variables within single quotes are not evaluated?


[Log in to get rid of this advertisement]
$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*
Akhran is offline     Reply With Quote
Old 03-10-2006, 09:32 PM   #2
PenguinPwrdBox
Member
 
Registered: Oct 2003
Location: /illinois/chicago
Distribution: Slackware/Gentoo/FC/RHEL
Posts: 568
Thanked: 0
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.
PenguinPwrdBox is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
Using single quotes vs double quotes in PHP strings hs123 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
Problems with quotes and double quotes Andruha Slackware 4 02-15-2005 10:44 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 10:15 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration