find - find files in Plan 9


news: Erik Quanstrom has modified and improved the find(1) command:
i had a need for a few features in find that your version didn't have. (optional rc quoting and control of mount traversal.) /n/sources/quanstro/find.tbz
FIND(1)                                                         FIND(1)

NAME

find ­ find files and directories on the system.

SYNOPSIS

find [ -f ] [ dir1 dir2 ... ]

DESCRIPTION

Find lists recursively all files under the directories supplied, or the current directory.
-f causes find to skip reporting any warnings and errors.

SOURCE

/sys/src/cmd/find.c

BUGS

No options familiar from lunix' find, such as -type and -name, available.
1

Download:
please use Erik's version from /n/sources/quanstro/find.tbz
Performance: approx twice faster than du -a + sed/awk:
	plan9% cat /bin/f
	#!/bin/rc
	
	dir=''
	switch ($#*) {
		case 0
			dir='.'
		case 1
			dir=$1
		case *
			dir=$*
	}
	
	for(i in $dir) {
		if(test -e $i) {
			du -a $i | sed 's/^[0-9]*	//;/^.$/d'
		}
		if not {
			echo $i^': not a file'
		}
	}
	plan9% time 8.find $home | wc -l
	1.30u 1.27s 6.02r 	 8.find /usr/andrey
	 220636
	plan9% time f $home | wc -l
	4.46u 1.89s 9.22r 	 f /usr/andrey
	 220636
	plan9% 


Todo: add something resembling '-type' in lunix' find. That's the only option i'm missing from there.

Note: there won't be a '-name'-like option added, use grep :)
Last Modified: July 31, 2004
mirtchovski at gmail