help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Simple echo is printing the wrong value


From: Chet Ramey
Subject: Re: [Help-bash] Simple echo is printing the wrong value
Date: Wed, 04 Apr 2012 16:03:47 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 4/4/12 1:29 PM, Bill Gradwohl wrote:

> With 2 files in the directory, one named * and the other named nonAsterisk,
> the for loop:
> for file in *; do
> produces file='*' on the first pass.
> The echo statement contains the unquoted $file which bash expands to 2
> parameters namely * and nonAsterisk.
> 
> Same goes for the func line.
> 
> Therefore these 2 statements get 2 passed parameters which is what I
> wanted, and got.

I cannot imagine any circumstances under which you would want to take
a valid, existing filename, and create from it an indeterminate number
of separate words.  Even if you wanted to act on the entire set of files
in the directory at the same time.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]