Re: Bash commands: maybe they want to drive us crazy?
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 07/01/04
- Previous message: Keith Keller: "Re: Bash commands: maybe they want to drive us crazy?"
- In reply to: GP: "Re: Bash commands: maybe they want to drive us crazy?"
- Next in thread: P.T. Breuer: "Re: Bash commands: maybe they want to drive us crazy?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Jul 2004 05:47:10 GMT
On 2004-07-01, GP wrote:
> 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 *
Quite right; Bill was wrong.
> Which means that a shell command and the shell itself are two very different
> things.
Of course they are two 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.
Exactly.
> Conclusion:
>
> Contrary to the pretention of Mr Unruh, there is absolutely no difference
> between a shell and a shell command interpretation.
What are you talking about??
A shell is a program that interprets commands (from the terminal
or from a file) according to strict and well-defined rules.
The shell parses the command line, performs various expansions,
and passes the result to the command as an array of arguments,
whether the command is built into the shell (cd, echo, type) or
is an external command (find, grep, date).
--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
===================================================================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Previous message: Keith Keller: "Re: Bash commands: maybe they want to drive us crazy?"
- In reply to: GP: "Re: Bash commands: maybe they want to drive us crazy?"
- Next in thread: P.T. Breuer: "Re: Bash commands: maybe they want to drive us crazy?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|