will only match files, not directories, symlinks etc.
ls **/*.jpg(.L-3000000on[1,5]) **/*.png(N)
will match .jpg files in the current and all subdirectories, which are:
. files
L-3000000 with "length" (size) under 3MB
on ordering them numerically
[1,5] and only the first five
plus any .png files, if they exist (N = it won't fail if they don't).
I have some scripts with expressions this complicated, but day-to-day it's useful for finding empty files (L0) or excluding directories. "man zshexpn" and search "Glob Qualifiers".
2) Glob operators:
ls DSC<100-200>.JPG
matches files with names between DSC100.JPG to DSC200.JPG.
setopt extended_glob
ls *.java~*Test*
matches all .java files, except those matching Test*. Same man page, search "Glob Operators".
3) Lazy for-loops (single command doesn't require do-done), and taking two variables:
echo "A 1" > tempfile
for i j in $(<tempfile); echo $i $j
Interactively, shell history seems to be nicer, I use a couple of global aliases (alias -g L='| less'), and the completion system completes everything you can possibly think of, like usernames, hostnames, remote filenames, HTTP URLs, processes (for kill)...
1) Glob qualifiers:
will only match files, not directories, symlinks etc. will match .jpg files in the current and all subdirectories, which are: plus any .png files, if they exist (N = it won't fail if they don't).I have some scripts with expressions this complicated, but day-to-day it's useful for finding empty files (L0) or excluding directories. "man zshexpn" and search "Glob Qualifiers".
2) Glob operators:
matches files with names between DSC100.JPG to DSC200.JPG. matches all .java files, except those matching Test*. Same man page, search "Glob Operators".3) Lazy for-loops (single command doesn't require do-done), and taking two variables:
4) Parameter expansion. Interactively, shell history seems to be nicer, I use a couple of global aliases (alias -g L='| less'), and the completion system completes everything you can possibly think of, like usernames, hostnames, remote filenames, HTTP URLs, processes (for kill)...