ZSH reference

Glob qualifiers

.plain files
@symbolic links
*executable plain files (0100)
wowner-writable files (0200)
Wworld-writable files (0002)
Ufiles owned by the effective user ID
^negates all qualifiers following it

File expansion

*(X^/)All executables but not directories
*(m0)Modified today
*(mw+1)Modified more than one week ago
*(mM-1)Modified within the last month
*(.oc[1])Newest created file
*(.om[1,3])3 newest modified file
*(.L+100)More than 100 Bytes
*(.Lm-10)Less than 10 MB
^xMatches anything except the pattern x
x~yMatch anything that matches the pattern x but does not match y.
(#i)patternCase insensitive match
(#a2)patternApproximate matching

History expansion

!!Last command
!01st word of last command
!^2nd word of last command (1st argument)
!$Last word of last command
!*All parameters of last command
!!22nd word of last command
!!-3 3rd last command
!!-3:22nd word of 3rd last command
!stringLast command starting with string
!?stringLast command that contains string
!?string?:$Last word of last command that contains string
^old^newReplace old in the last command by new
r old=newReplace old in the last command by new
!#Current line
!#*:gs/old/newSubstitute old in current line parameters by new

Other expansions

=lsExpando to the command binary file: /bin/ls
=(uname -a)Expand to a temporary file with the output of the command


zmv '* *' '$f:gs/ /_'Replace spaces in filenames with a underline
zmv -W '*.sh' '*.pl'Change the suffix from *.sh to *.pl
zmv '(*)' '${(L)1}'lowercase all
zmv '(*)' '${(U)1}'uppercase all


cd old newChange directory from ../...old.../.. to ../...new.../..
cd ~5cd to fifth directory in directory stack