zsh-users
 help / color / mirror / code / Atom feed
* ranges
@ 2005-06-01 15:42 zzapper
  2005-06-01 16:28 ` ranges Christian Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: zzapper @ 2005-06-01 15:42 UTC (permalink / raw)
  To: zsh-users

Hi,

ls fred{09..13}.pl
ls fred<76-99>.pl  
ls fred<76->.pl  

Are these really different?

ls *.(jpg|gif)   # list graphic files
ls fred{joe,sid}.pl

Are these really different?

-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ranges
  2005-06-01 15:42 ranges zzapper
@ 2005-06-01 16:28 ` Christian Taylor
  2005-06-02  7:02   ` ranges zzapper
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Taylor @ 2005-06-01 16:28 UTC (permalink / raw)
  To: zsh-users

All right, let's hope I don't write too much nonsense...

> ls fred{09..13}.pl
> ls fred<76-99>.pl
> ls fred<76->.pl
>
> Are these really different?

"ls fred{09..13}.pl" = "ls fred09.pl fred10.pl fred11.pl fred12.pl fred13.pl"
This is just expanded by the shell, no matter which of those files actually 
exist.
"ls fred<76-99>.pl" = "ls <all matching files>"
The shell inserts only existing files which match the specified criterium.
"ls fred<76->.pl" is like the above, but would match any number greater than 
75, for instance fred28742.pl

> ls *.(jpg|gif)   # list graphic files
> ls fred{joe,sid}.pl
>
> Are these really different?

"ls *.(jpg|gif)" = "ls <all matching files>"
"ls fred{joe,sid}.pl" = "ls fredjoe.pl fredsid.pl"

Hope this helps,

Christian Taylor


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ranges
  2005-06-01 16:28 ` ranges Christian Taylor
@ 2005-06-02  7:02   ` zzapper
  2005-06-02 13:57     ` ranges Christian Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: zzapper @ 2005-06-02  7:02 UTC (permalink / raw)
  To: zsh-users

On Wed, 1 Jun 2005 18:28:32 +0200,  wrote:

To summarise
>
>> ls fred{09..13}.pl  # noisy
>> ls fred<76-99>.pl # silent
>> ls fred<76->.pl     # cute

> but surely following are identical?
>> ls *.(jpg|gif)   # 
>> ls *.{jpg,gif}  # 
>>



-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ranges
  2005-06-02  7:02   ` ranges zzapper
@ 2005-06-02 13:57     ` Christian Taylor
  2005-06-02 16:19       ` ranges Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Taylor @ 2005-06-02 13:57 UTC (permalink / raw)
  To: zsh-users

On Thursday 02 June 2005 09:02, you wrote:
> To summarise
>
> >> ls fred{09..13}.pl  # noisy
> >> ls fred<76-99>.pl # silent
> >> ls fred<76->.pl     # cute

Well, the first form is for things like "touch fred{09..13}.pl"

> > but surely following are identical?
> >
> >> ls *.(jpg|gif)   #
> >> ls *.{jpg,gif}  #

No! The first one uses zsh globbing to give ls the matching files, the second 
one first expands the command to "ls *.jpg *.gif" and works from there. Just 
try it in a folder with some .jpg files but no .gif files.

Christian Taylor


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ranges
  2005-06-02 13:57     ` ranges Christian Taylor
@ 2005-06-02 16:19       ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2005-06-02 16:19 UTC (permalink / raw)
  To: zsh-users

When discussing {N..M} and {X,Y} in comparison to <N-M> and (X|Y), the
most important thing to keep in mind is:

Brace expansions create new strings.  Patterns select existing strings.

For example, [[ 7 = {1..9} ]] is nonsense, but [[ 7 = <1-9> ]] works.

David's summary goes wrong as soon as "ls" becomes the example command,
because that egregiously translates all the strings into the namespace
of existing files.  Neither braces nor patterns inherently operate on
files. (*)  A better example would have used "print" or "echo".


(*  Some glob qualifiers operate on files, but that's independent of the
pattern part.  The seeming special case of slashes in globbing occurs
not because the patterns are matched differently, but because globbing
interprets a series of patterns separated by slashes, comparing each
pattern in the series to a different set of existing strings, each set
happening to consist of file names.)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-06-02 16:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-01 15:42 ranges zzapper
2005-06-01 16:28 ` ranges Christian Taylor
2005-06-02  7:02   ` ranges zzapper
2005-06-02 13:57     ` ranges Christian Taylor
2005-06-02 16:19       ` ranges Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).