# List all files older than 15mins
$ ls -ldrt -- *(mm+15)
# Just regular files
$ ls -ldrt -- *(.mm+15)
# the age of the pointed to file for symlinks
$ ls -Lldrt -- *(-mm+15)
# Use find(1) to find all directories except the ".svn" ones, then use grep on all *.c/*.h/*.S
# files in each directory.
$ setopt extendedglob
$ grep pattern (^.svn/)#*.[xhS](.) # skips dot files and dot directories
# or - without Zsh
$ find . -type d ! -name .svn | sed 's/./\\&/g;s|.*|grep whatever &/*.[xhS]|' | sh
# Quote from Usenet
# > I need to write a script that searches through a folder on my Linux
# > home server and copies only files where the width is greater than the
# > height, but it also needs to flatten the directory structure and
# > rename files as it copies. So the first picture found may be several
# > directories deep in the source but this should be copied to the root
# > of the SD card and named say 00000001.JPG and the next file found
# > where width > height should be copied and renamed 00000002.JPG.
width_greater_than_height() {
local w h
identify -format '%w %h' ${1-$REPLY} |
read w h && ((w > h))
}
typeset -Z8 i=0
setopt extendedglob
for f (**/*.(#i)jp(e|)g(D.+width_greater_than_height)) {
((i++))
cp -- $f /path/to/dest/$i.JPG
}
# remove leading zeros
$ var=00004402
$ echo ${var##0#}
# or
$ var=00004402
$ echo ${var/(#m)<->/$((MATCH))}
# find all directories, list their contents and output the first item in the above list.
$ print -rl /home/me/**/*(D/e{'reply=($REPLY/*(N[-1]:t))'})
# rename a section of a filename, i. e. example.1.{txt,conf,db} or 12345.1.{wav,ogg,mp3} and
# change the 1 to a 2 in the filename while preserving the rest of it.
$ zmv -n '(*.)(<->)(.[^.]#)' '$1$(($2+1))$3' # would rename x.0001.y to x.2.y.
$ zmv -n '(*.0#)(<->)(.[^.]#)' '$1$(($2+1))$3'
# Rename files to lower case
$ zmv '*' '${(L)f}'
Mental note to self: fortune(6)-Cookies, meine
Zsh-Seite und zsh-lovers(1) aktualisieren und das
zsh-lovers - Repo von
grml.org sync'en.