FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 02-02-2011, 07:43 PM
Petrus de Calguarium
 
Default putting something into single quotes in a bash script

What is the difference in a bash script when one places something between
single quotes:

- using the apostrophe, '
- using the accent grave, `

?

Eg.,

ps -fu 'whoami'
ps -fu `whoami`

They produce entirely different results.

There are many other places where one might wish to put a command, variable,
etc., into single quotes, so, which type of single quote sahould be used and
what is the diffence between the two?

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 07:51 PM
Michael Cronenworth
 
Default putting something into single quotes in a bash script

Petrus de Calguarium wrote:
> ps -fu 'whoami'

This just passes the text whoami as a group argument with no execution
of whoami.

ps -fu whoami
^
Equivalent command

> ps -fu `whoami`

The accent graves tell bash to execute the text inside them. The whoami
command will be executed then passed to ps -fu.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 08:03 PM
g
 
Default putting something into single quotes in a bash script

On 02/02/2011 08:43 PM, Petrus de Calguarium wrote:
> What is the difference in a bash script when one places something between
> single quotes:

single/double quotes and grave are something i tend to forget sometimes.

i find it quicker, easier and refreshing to run

man bash

the search on the work *quote*.

if i use then incorrectly enough, it will sink in and i will not have
to keep looking them up.


--

peace out.

tc.hago,

g
.

****
in a free world without fences, who needs gates.
**
help microsoft stamp out piracy - give linux to a friend today.
**
to mess up a linux box, you need to work at it.
to mess up an ms windows box, you just need to *look* at it.
**
learn linux:
'Rute User's Tutorial and Exposition' http://rute.2038bug.com/index.html
'The Linux Documentation Project' http://www.tldp.org/
'LDP HOWTO-index' http://www.tldp.org/HOWTO/HOWTO-INDEX/index.html
'HowtoForge' http://howtoforge.com/
****

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 08:32 PM
Patrick O'Callaghan
 
Default putting something into single quotes in a bash script

On Wed, 2011-02-02 at 13:43 -0700, Petrus de Calguarium wrote:
> What is the difference in a bash script when one places something between
> single quotes:
>
> - using the apostrophe, '
> - using the accent grave, `
>
> ?
>
> Eg.,
>
> ps -fu 'whoami'
> ps -fu `whoami`
>
> They produce entirely different results.

Of course they do. They are entirely different things. The first one is
for quoting strings which might contain Shell metacharacters. The second
is to execute a command and insert its output as the value of the
string, e.g.

ls -l `find ~/.kde`

This is equivalent to:

ls -l $(find ~/.kde)

but the latter is a more recent form (it has the advantage of being
nestable, which the older form isn't).

And then there's the difference between " and ' ...

I recommend reading up on bash to fully understand this last part. It's
not trivial to explain.

poc

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 09:10 PM
g
 
Default putting something into single quotes in a bash script

On 02/02/2011 09:32 PM, Patrick O'Callaghan wrote:
<>

> I recommend reading up on bash to fully understand this last part. It's
> not trivial to explain.

or to understand.


--

peace out.

tc.hago,

g
.

[just for you, poc. (GBWG)]


--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 09:55 PM
Joe Zeff
 
Default putting something into single quotes in a bash script

On 02/02/2011 01:32 PM, Patrick O'Callaghan wrote:
> I recommend reading up on bash to fully understand this last part. It's
> not trivial to explain.

You might find what you need at http://tldp.org/LDP/abs/html/
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 11:41 PM
Petrus de Calguarium
 
Default putting something into single quotes in a bash script

Patrick O'Callaghan wrote:

> Of course they do. They are entirely different things. The first one is
> for quoting strings which might contain Shell metacharacters. The second
> is to execute a command and insert its output as the value of the
> string, e.g.
>
> ls -l `find ~/.kde`
>
> This is equivalent to:
>
> ls -l $(find ~/.kde)
>
> but the latter is a more recent form (it has the advantage of being
> nestable, which the older form isn't).

Thank you. That explains it well.

I will read up a bit, too.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 11:57 PM
Petrus de Calguarium
 
Default putting something into single quotes in a bash script

Joe Zeff wrote:

> You might find what you need at http://tldp.org/LDP/abs/html/

Thanks for the suggestion, but I don't have the time to read a book just to
find out the meaning of ` and learn that it is not the same as '.




--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-02-2011, 11:59 PM
Petrus de Calguarium
 
Default putting something into single quotes in a bash script

g wrote:

> man bash

The man page for bash is the worst one of all! I use man all the time for all
kinds of commands, but anything to do with bash directs you to this bash page,
meaning you have to pore over hundreds of separate entries in the vain hope of
finding something relevant to your query.

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 02-03-2011, 01:42 AM
g
 
Default putting something into single quotes in a bash script

On 02/03/2011 12:59 AM, Petrus de Calguarium wrote:
<>

> The man page for bash is the worst one of all!

not really. using '/' to look for what you want to know about makes it
very informative. at least for me. maybe not for some who are not used
to man pages.

> I use man all the time for all kinds of commands, but anything to
> do with bash directs you to this bash page,

actually, only 6;

sh(1), ksh(1), csh(1), emacs(1), vi(1), readline(3)

of which, 'sh(1)' kicks back to 'man bash'. while ksh(1) and csh(1) do
have one hell of a lot more 'see also'.

first 4 'see also' are manuals and references for readings outside of man.

> meaning you have to pore over hundreds of separate entries in the
> vain hope of finding something relevant to your query.

only if i do not comprehend what i am reading in said man page.


--

peace out.

tc.hago,

g
.

****
in a free world without fences, who needs gates.
**
help microsoft stamp out piracy - give linux to a friend today.
**
to mess up a linux box, you need to work at it.
to mess up an ms windows box, you just need to *look* at it.
**
learn linux:
'Rute User's Tutorial and Exposition' http://rute.2038bug.com/index.html
'The Linux Documentation Project' http://www.tldp.org/
'LDP HOWTO-index' http://www.tldp.org/HOWTO/HOWTO-INDEX/index.html
'HowtoForge' http://howtoforge.com/
****

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 

Thread Tools




All times are GMT. The time now is 06:50 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org