Search code examples
zshglob

What is the meaning of each parameter for *(*ocNY1) from the shell command `echo`?


I could not find the proper place to look up for the parameter explanation for the below command.

echo *(*ocNY1)

After some tests, I discovered that *(*oc) prints executable files(file with x permission) from the current directory. And NY1 prints the first item of such. But I cannot find the manual for such options. Where can I find the definition/manual for the parameters of such?

Where can I lookup to see the explanation for each parameters for the pattern matching? Is this glob pattern or regex that echo is using?

Sometimes it is really hard to take the first step if you do not know where you are heading.


Solution

  • *(*ocNY1) is a zsh glob pattern - see man zshexpn.

    * is a glob operator that matches any string, including the null string.

    The trailing (...) contains glob qualifiers:

    • * to match executable plain files
    • oc sort by time of last inode change, youngest first
    • N sets the nullglob option for the current pattern
    • Yn expand to at most n filenames