Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In zsh, there is the [m,n] glob qualifier which works as follows:


specifies which of the matched filenames should be included in the returned list. The syntax is the same as for array subscripts. beg and the optional end may be mathematical expressions. As in parameter subscripting they may be negative to make them count from the last match backward. E.g.: ‘*(-OL[1,3])’ gives a list of the names of the three largest files.

So for example, if I type:

print *([2,10]) 

it will return the elements 2 to 10 matched by *.

My question is: How can I ask zsh to return the matched elements starting from element X to the end of the list?

For example say I have 2500 files in one folder, BUT I don't know this number, and I would like to match all files starting from file 160.

I have tried:

1) print -l *([160])

-> only matches file # 160.

2) print -l *([160,])

-> No matches found

3) print -l *~*([1,160])

-> No matches found

share|improve this question
up vote 1 down vote accepted

A negative number counts from the end. The last element is -1.

print -l *([160,-1])

If you wanted the last 42:

print -l *([-42,-1])
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.