Posts from '2005' - 2
Tip #64 - List all files which have not been updated since last 10 hours
print -rl -- *(Dmh+10^/) For comments, please send me an email read more →
Tip #63 - Change the UID from 102 to 666
$ chown 666 **/*(u102) For comments, please send me an email read more →
Tip #62 - A User's Guide to the Z-Shell /5.9: Filename Generation and Pattern Matching
# find all files in all subdirectories, searching recursively, which have a given # name, case insensitive, are at least 50 KB large, no more than a week old and # owned by the root user, and allowing up to a single error in the spelling of # t ... read more →
Tip #61 - find and delete the files which are older than a given parameter (seconds/minutes/hours)
$ rm -f /Dir/**/*(.mh+3) # deletes all regular file in /Dir that are older than 3 hours $ rm -f /Dir/**/*(@mm+3) # deletes all symlinks in /Dir that are older than 3 minutes $ rm -f /Dir/**/*(ms+30^/) # deletes all non dirs in /Dir that a ... read more →
Tip #60 - List files in the current directory are not writable by the owner
$ print -l ~/*(ND.^w) For comments, please send me an email read more →
Tip #59 - Show only world-readable files
$ ls -l *(R) For comments, please send me an email read more →
Tip #58 - show data to *really* binary format
$ zsh -ec 'while {} {printf %.8x $n;repeat 8 \ > {read -ku0 a printf \ %.8d $(([##2]#a))};print;((n+=8))}' < binary For comments, please send me an email read more →
Tip #57 - Show only all *.c - files and ignore `foo.c'
ls *.c~foo.c For comments, please send me an email read more →
Tip #56 - Show only all *.c and *.h - Files
$ ls -l *.(c|h) For comments, please send me an email read more →
Tip #55 - remove spaces from filenames
$ for a in ./**/*\ *(Dod); do mv $a ${a:h}/${a:t:gs/ /_}; done For comments, please send me an email read more →
Tip #54 - get all files that begin with the date strings from June 4 through June 9 of 2004
$ ls -l 200406{04..10}*(N) # or if they are of the form 200406XX (require ``setopt extended_glob'' $ ls -l 200306<4-10>.* For comments, please send me an email read more →
Tip #53 - List files beginning at `foo23' upwards (foo23, foo24, foo25, ..)
$ ls -l foo<23-> For comments, please send me an email read more →
Tip #52 - Search all files in /home/*/*-mail/ with a setting ``chmod -s'' flag
(recursive, include dotfiles) remove the setgid/setuid flag and print a message $ chmod -s /home/*/*-mail(DNs,S) /home/*/*-mail/**/*(DNs,S)) # or with a small script $ for file (/home/*/*-mail(DNs,S) /home/*/*-mail/**/*(DNs,S)) { > print - ... read more →
Tip #51 - print out all of the files in that directory in 2 columns
$ print -rC2 -- ${1:[...]}/*(D:t) # ^- number ob columns or - if you feel concerned about special characters - use $ list=(${1:[...]}/*(ND:t) $ (($#list)) && print -rC2 -- ${(V)list} For comments, please send me an email read more →
Tip #50 - Find files with size == 0 and send a mail
$ files=(**/*(ND.L0m+0m-2)) > (( $#files > 0 )) && print -rl -- $files | mailx -s "empty files" foo@bar.tdl For comments, please send me an email read more →
Tip #49 - Print the path of the directories holding the ten biggest C regular files
$ print -rl -- **/*.c(D.OL[1,10]:h) | sort -u For comments, please send me an email read more →
Tip #48 - case insensitive checking for variables
$ if [[ $OSTYPE == (#i)LINUX*(#I) ]]; then > echo "Penguin on board." > else > echo "Not a Linux." > fi For comments, please send me an email read more →
Tip #47 - List all `README' - files case-insensitive with max. one type
$ ls **/*(#ia2)readme For comments, please send me an email read more →
Tip #46 - Match all .c files in all subdirectories, _except_ any SCCS subdirectories
$ ls **/*.c~(*/)#SCCS/* For comments, please send me an email read more →
Tip #45 - Lists every executable in PATH
$ print -l ${^path}/*(-*N) For comments, please send me an email read more →