9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Martin Weitzel Martin.Weitzel@rent-a-guru.de
Subject: where is 'find'?
Date: Sat, 30 Sep 1995 15:46:46 -0400	[thread overview]
Message-ID: <19950930194646.Uro5ffamXQ7l1hlPDNEyp-vpEQxtozHirejCLBZAP8k@z> (raw)

> 
> 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






             reply	other threads:[~1995-09-30 19:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-09-30 19:46 Martin [this message]
  -- strict thread matches above, loose matches on Subject: below --
1995-10-08 19:19 stephen
1995-10-08 19:17 stephen
1995-10-04 14:19 Jeremy
1995-10-04  5:55 ME
1995-09-30 17:27 Jeremy
1995-09-30 15:00 John
1995-09-30  4:30 Scott
1995-09-27 15:26 Steve
1995-09-27 13:06 presotto
1995-09-27  7:11 Kenji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19950930194646.Uro5ffamXQ7l1hlPDNEyp-vpEQxtozHirejCLBZAP8k@z \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).