1

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

[beg[,end]]

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

1

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])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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