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?
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.
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. :)
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.
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.
On 02/03/2011 07:41 PM, Joe Zeff wrote: <>
Man uses less for display. To learn more about it, use
this is true. but then he would have to have 2 terminal windows open until he learns more commands. ;)
after which, he can learn 'info', as poc suggested, and then he will have a whole new command group to learn. :)
btw. pressing <h> in 'info' gives help information also.
man less
gives more command information than what is used in 'man'.
On 02/03/2011 06:49 PM, Petrus de Calguarium wrote: <>
Actually, I am intimately familiar with man pages; however, the only commands I know are space bar, 'b', 'q' and the mouse wheel.
then you need to become more intimate with 'man'.
run;
man man
while there, press <h> key.
may you intimacy become a joy. :)
On Wed, 2011-02-02 at 17:59 -0700, Petrus de Calguarium wrote:
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.
info bash
poc
On 02/02/2011 07:09 PM, Patrick O'Callaghan wrote:
On Wed, 2011-02-02 at 17:59 -0700, Petrus de Calguarium wrote:
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.
info bash
poc
See the Advanced Bash Scripting Guide at
tldp.org/LDP/abs/html/
Regards
John
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
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/
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 '.
On Wed, Feb 2, 2011 at 4:57 PM, Petrus de Calguarium pgueckel@gmail.com wrote:
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 '.
Learning to use the shell effectively requires a bit of patience. Let me make it a little easier for you,
http://tldp.org/LDP/abs/html/quoting.html http://tldp.org/LDP/abs/html/varsubn.html http://tldp.org/LDP/abs/html/commandsub.html
HTH
On 02/02/2011 10:55 PM, Joe Zeff wrote:
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/
i believe poc was just stating that 'recent form' requires more explaining than what he did in simplifying 'grave'. is, 'rtfmp'.
i do agree with you about 'tldp' having plenty of information. they do live up to their name.
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.