From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 30 Sep 1995 15:46:46 -0400 From: Martin Weitzel Martin.Weitzel@rent-a-guru.de Subject: where is 'find'? Topicbox-Message-UUID: 29c3c752-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19950930194646.Uro5ffamXQ7l1hlPDNEyp-vpEQxtozHirejCLBZAP8k@z> > > On Sep 27, 3:11am, Kenji Okamoto wrote: > > Subject: where is 'find'? > > Subject says enough, I expect. > > I wrote a little program to descend a directory tree and print all the > files it finds. In combination with some 1-line scripts with grep in > them, I find it makes an adequite replacement. > > J There was another solution mentioning "du" and further selection by "awk". All of this doesn't quite replace "find", as the latter has numerous selection criteria for the files (size, owner, modicfication time, etc). So I'm willing to contribute "fstat" to the Plan 9 community. It's a classical Unix filter program. On its one end, you stuff in file names, on the other end you get "status information" for those files (of course including their names, if you want). To select what information you want to see in which format, you have to supply a "format string" as command line argument. In this string, some dozen %-placeholders allow to select every bit of the (Unix-) inode data. (The style is similar to the Unix command date(1) with a "+format" parameter). Sometimes you have a choice between a more "internal" representation (e.g. "mtime" in seconds since the epoch) and a more "human readable" one (e.g. "mtime" in YYMMDDhhmmss). On the other hand, "fstat" mostly follows a `minimal approach' (e.g. it doesn't offer "mtime" in any other fancy format - date US style, Eropean style). In general, having output all the inode's data you need, the next program in the pipeline will probably be "grep" or "awk" to select files according to any desired criteria and - if required - also do any fancy formatting. An additional sort step between "fstat" and the final selection/formatting is also possible, so you can sort the generated file names according to almost anyting you like (mtime, size, owner, type ...). Of course, "fstat" is written for Unix, but porting to Plan 9 should not at all be hard. It might be necessary to add a few more %-placeholders or disable some, reflecting differences in a file's status data between Unix and Plan 9, but all that will be straight forward. I'd do a port myself, but I can't because my Plan 9 test system went down a few hour ago. (Either the VGA card or the motherboard failed. Besides I cannot replace anything before Monday and because of more urgent work I fear a port would have to wait until late October.) So I offer the chance to someone else. Mail me and I'll send you the source. BTW: As described above, "fstat" is a pleasure to use on Unix too. Being limited to "find" and "ls -l", it's hard to display certain combinations of information about the files found (e.g. "owner" by name and by UID or "mtime" together with "atime"), furthermore, the change in "ls -l" output format for dates, if a time stamp is older than half a year, often makes post processing cumbersome. --Martin