Zsh glob qualifiers narrow a pathname match before the command sees it. They help when a broad pattern such as *.log would include files with the wrong type or permission state, especially before cleanup or permission commands.

A qualifier sits in parentheses at the end of the pattern. (.) keeps plain files, (/) keeps directories, and (*) keeps executable plain files. Qualifiers are part of the glob, so reports/*.log(.) returns plain log files and leaves non-log files out of expansion.

The example below builds a temporary tree under /tmp/zsh-glob-demo and previews each match with print -rl --. That output is the safety check to read before reusing the same pattern with rm, chmod, or another command that changes paths.

Steps to use glob qualifiers in Zsh:

  1. Create a safe workspace with separate report and archive directories.
    $ mkdir -p /tmp/zsh-glob-demo/reports /tmp/zsh-glob-demo/archive
  2. Enter the workspace before testing relative patterns.
    $ cd /tmp/zsh-glob-demo
  3. Create the first log file.
    $ printf 'one\n' > reports/app.log
  4. Create the second log file.
    $ printf 'two\n' > reports/db.log
  5. Create a non-log file beside the log files.
    $ printf 'note\n' > reports/readme.txt
  6. Mark one log file executable.
    $ chmod u+x reports/db.log
  7. List only plain log files.
    $ print -rl -- reports/*.log(.)
    reports/app.log
    reports/db.log

    The (.) qualifier keeps the match to plain files.

  8. List only directories in the current location.
    $ print -rl -- *(/)
    archive
    reports

    The (/) qualifier matches directories, so files under reports/ are not returned by this pattern.

  9. List executable plain files under the reports/ directory with the (*) qualifier.
    $ print -rl -- reports/*(*)
    reports/db.log

    Globs are expanded before the command runs. Preview new qualifiers with print -rl -- PATTERN before passing the same pattern to rm, chmod, or another command that changes files.

  10. Leave the test workspace.
    $ cd /tmp
  11. Remove the temporary workspace.
    $ rm -rf /tmp/zsh-glob-demo