Modifiers are a powerful mechanism that let you modify the results returned by parameter, filename, and history expansion.

Following is a list of modifiers available as of zsh-3.1.5.


Modifiers marked with < H > work only with history expansion.
Modifiers marked with < FP > work only with filename and parameter expansion.

Remove a trailing pathname component, leaving the head.

Remove a trailing suffix of the form `.xxx', leaving the basename

Remove all but the suffix

Remove all leading pathname components, leaving the tail

p < H >
Print the new command but do not execute it

q < H >
Quote the substituted words, escaping further substitutions

x < H >
Like q, but break into words at each blank

Convert the words to all lowercase

Convert the words to all uppercase

f < FP >
Repeats the immediately (without a colon) following modifier until the resulting word doesn't change any more.

F:expr: < FP >
Like f, but repeats only n times if the expression expr evaluates to n. Any character can be used instead of the `:', if any of `(', `[', or `{' is used as the opening delimiter the second one has to be ')', `]', or `}' respectively.

w < FP >
Makes the immediately following modifier work on each word in the string.

W:sep: < FP >
Like w but words are considered to be the parts of the string that are separated by sep. Any character can be used instead of the `:'; opening parentheses are handled specially, see above.

Substitute r for l as described below. Unless preceded immediately by a g, with no colon between, the substitution is done only for the first string that matches l. For arrays and filename expansion, this applies to each word of the expanded text.

Repeat the previous s substitution. Like s, may be preceded immediately by a g. In variable expansion the & must appear inside braces, and in filename expansion it must be quoted with a backslash.

The s/l/r/ substitution works as follows.