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 04-05-2004, 02:26 AM   #1
davidas
Member
 
Registered: Mar 2004
Distribution: Debian 'Sarge'
Posts: 168

Rep: Reputation: 30
In BASH shell, what is the difference in usage between single and double quotes?


Eg. what's the difference between

1) alias ls='ls --color' and alias ls="ls --color"

2) find ./ -name '.bash*' and find ./ -name ".bash*"

The output seems to be similar. (?)

Under what circumstances would the difference be significant?

Thanks !
 
Old 04-05-2004, 02:37 AM   #2
batchild
LQ Newbie
 
Registered: May 2003
Location: Colorado Springs, CO
Distribution: Red Hat V7/V9/AS/Fedora
Posts: 22

Rep: Reputation: 15
Hello,

Good explanation here:
http://www.injunea.demon.co.uk/pages/page206.htm

..........

Quoting and Escaping

The difference between the single and double quote are also useful to know. The single quote is what you use to enclose a literal string. Whatever is between single quotes remains unchanged by the shell. If you enclose something in double quotes then concatenated blanks are preserved (as in the literal case with the single quotes) but variables are substituted by their values and filenames are expanded from their wild-cards to full filenames and or paths. The best way to see this is in the example below.

Example quoting
my_name="Fred Smith" # Set a variable
echo "$my_name" # Will output - Fred Smith
echo '$my_name' # Will output - $my_name

............

--John Lanier
 
Old 04-05-2004, 03:00 AM   #3
davidas
Member
 
Registered: Mar 2004
Distribution: Debian 'Sarge'
Posts: 168

Original Poster
Rep: Reputation: 30
Thanks batchild! Exactly what I need.


Quote:
Originally posted by batchild
Hello,

Good explanation here:
http://www.injunea.demon.co.uk/pages/page206.htm

..........

Quoting and Escaping

The difference between the single and double quote are also useful to know. The single quote is what you use to enclose a literal string. Whatever is between single quotes remains unchanged by the shell. If you enclose something in double quotes then concatenated blanks are preserved (as in the literal case with the single quotes) but variables are substituted by their values and filenames are expanded from their wild-cards to full filenames and or paths. The best way to see this is in the example below.

Example quoting
my_name="Fred Smith" # Set a variable
echo "$my_name" # Will output - Fred Smith
echo '$my_name' # Will output - $my_name

............

--John Lanier
 
  


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 04:44 PM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 11:41 AM
replacing single quotes in file names adenardo Linux - General 2 05-27-2005 11:29 AM
US Intl Keybd; Double quotes not showing in some apps Heinz Linux - General 6 01-10-2004 03:48 PM
Whats the difference Linux Console and BASH Shell glenn69 Linux - Newbie 2 08-31-2003 03:19 PM


All times are GMT -5. The time now is 11:37 PM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration