Re: Bash commands: maybe they want to drive us crazy?

From: GP (gilpel_at_inverse.nretla.org)
Date: 07/01/04


Date: Wed, 30 Jun 2004 23:48:28 -0400

Bill Unruh wrote:

> ]find -iname . "*IPv6*"
>
> -iname is an option which takes one argument. That argument to the option in this case is
> '*IPV6*' (NOT "*IPv6*" because the latter would cause the shell to expand
> the *s, not find)

Ok. Let's examine this first argument. Mr Unruh pretends that

double quotes cause the shell to expand the *

whereas

single quotes would cause the find command to expand the *

Which means that a shell command and the shell itself are two very different
things.

Well... if that's not new Linux to you, it certainly is to me and there is
absolutely no doubt I could have a rather lenghty discussion on the matter.
But, since "I" know nothing, in a socratian kind of way, I'll let my system answer.

EVERYTHING YOU ALWAYS WANTED TO KNOW ABOUT QUOTES
(but were too afraid to ask ;)

~$ echo `$LOGNAME`
-bash: gp: command not found

The shell seems to expect a command inside back quotes (or back ticks, as they
are often refered to). It's not pleased with a variable. Let's feed it a command!

~$ echo `ps`
PID TTY TIME CMD 1779 pts/2 00:00:00 bash 1856 pts/2 00:00:00 ps

The shell interprets the command.

~$ echo '$LOGNAME'
$LOGNAME

Here, the single quotes turns the shell into parrot. Let's feed it a command.

~$ echo 'ps'
ps

Same here. Sorry for this abominable untechnical language, but the single
quotes do turn the shell into a parrot.

~$ echo "$LOGNAME"
gp

Double quotes expand the variable into its value.

~$ echo "ps"
ps

But dumbly echo the command exactly as single quotes do.

As we all know:

If we include something inside of double-quotes, everything loses its special
meaning except for the variable operator ($), the back-slash (\), the back-tick (`)

http://www.linux-tutorial.info/modules.php?name=Tutorial&pageid=20

Thanks Linux tutorial!

So, please cd to /etc and issue the following commands:

find . -iname '*net*'
find . -iname "*net*"

What's the difference? None! Why? Because, since there is no $ , \ or `` inside
the double quotes, it is exactly equivalent to single quotes.

Conclusion:

Contrary to the pretention of Mr Unruh, there is absolutely no difference
between a shell and a shell command interpretation.

This being a very basic matter, either Mr Unruh is a dummy posing as an expert
or he's a troll. Lady and gents, the choice is yours.

What? Yes, of course, Mr Unruh, you may engrave my name 'till' the end of times
in your kill file. My pleasure! So can you, Mr Davidson. I don't need your
/advice/ and I do believe nobody here does.

Best regards!

GP



Relevant Pages

  • Re: Bash commands: maybe they want to drive us crazy?
    ... > Bill Unruh wrote: ... > single quotes would cause the find command to expand the * ... > Which means that a shell command and the shell itself are two very different ...
    (comp.os.linux.misc)
  • Re: Background subprocess help?
    ... This description does not correspond to the command above. ... command is confusing because it uses quotes in a strange way. ... meant at the linguistic level and the inner quotes are shell quotes. ... d> processes and/or callbacks and 50+ lines of python code. ...
    (comp.lang.python)
  • Re: Using Shell command
    ... >From what I've been able to tell, Shell doesn't like Start. ... Single quotes wouldn't work, Paint didn't like them, so I had to double up ... The vbmaximizedfocus works on the command window, ... Start would just open another command window with the item in quotes as the ...
    (microsoft.public.access.modulesdaovba)
  • Re: Bash commands: maybe they want to drive us crazy?
    ... > single quotes would cause the find command to expand the * ... > The shell seems to expect a command inside back quotes (or back ticks, ... the single quotes turns the shell into parrot. ...
    (comp.os.linux.misc)
  • Bash-4.0 available for FTP
    ... Unlike previous bash distributions, this tar file includes the formatted ... The shell has been changed to be more ... rigorous about parsing commands inside command substitutions, ... Changes have been made to the Readline library being released at ...
    (gnu.announce)