All of lore.kernel.org
 help / color / mirror / Atom feed
From: Evan Hunt <ethanol@armory.com>
To: Karel Zak <kzak@redhat.com>
Cc: Albert Cahalan <acahalan@gmail.com>,
	Bryan Henderson <bryanh@giraffe-data.com>,
	ams@gnu.org, P@draigbrady.com, util-linux-ng@vger.kernel.org
Subject: Re: splitting util-linux (was: kill)
Date: Fri, 22 Dec 2006 00:45:21 -0800	[thread overview]
Message-ID: <20061222084521.GB10592@armory.com> (raw)
In-Reply-To: <20061222080721.GS5971@petra.dvoda.cz>


>  Yes, the definition of "look" is pretty exact. Who do you think that
>  the tool should be work with any other type of files or with
>  a different ordering ? Now, it seems like right tool for right job.

It works well for looking up words in a dictionary file.  It doesn't work
very well for looking up lines in a flat-file database.

Consider a flat file like the following, each line containing a name,
a serial number, and some additional information.  Each time a new
transaction comes in, the serial number is incremented and a record
is added to the end of the file:

John:White:1:...
Mary:Brown:2:...
Fred:Green:3:...

...and so on.  Now, if that file grows very large, it would be useful to
be able to rapidly search it based on the serial number, e.g., something
like this:

$ search -n -t: -k3 97273 <filename>

Right now, the closest you can get to this with a standard unix or linux
tool is to use "look", but that only works if the serial number is the
first field of the file... and even then it doesn't work very well, because
the file has to be lexically sorted, so the serial numbers would all have
to be padded to the same length with leading zeroes.  It's faster than
using awk or grep, but it's a hassle.

I must have written a dozen shell scripts over the years that would have
been faster and easier to write if a tool like this had existed, and I
can't be the only one...

So I've finally gotten around to writing such a tool, and I'm calling
it "search" or "bs" (for "binary search") or something along those lines.
But I figured, well, it's almost identical to "look" when called without
arguments, so why not just supplant the existing "look"?  If it's invoked
as "look <word>", then it looks up the word in /usr/share/dict/words; if
it's invoked as "search -args <word> <filename>" then it's a general-
purpose binary search tool.

I'm still playing with it, but I plan to have it ready to contribute in
another few days.

Evan Hunt


  reply	other threads:[~2006-12-22  8:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20  6:42 util-linux: orphan Albert Cahalan
2006-12-20  8:57 ` kill (was: Re: util-linux: orphan) Karel Zak
2006-12-20 10:03   ` kill Pádraig Brady
2006-12-20 10:45     ` kill Karel Zak
2006-12-20 21:45       ` kill Alfred M. Szmidt
2006-12-20 23:55         ` kill Karel Zak
2006-12-21  4:10           ` kill Evan Hunt
2006-12-21 16:34             ` splitting util-linux (was: kill) Bryan Henderson
2006-12-21 21:53               ` Karel Zak
2006-12-22  6:12                 ` Albert Cahalan
2006-12-22  7:13                   ` Bryan Henderson
2006-12-22  9:06                     ` Albert Cahalan
2006-12-22  7:23                   ` Bryan Henderson
2006-12-22  7:45                   ` Evan Hunt
2006-12-22  8:07                     ` Karel Zak
2006-12-22  8:45                       ` Evan Hunt [this message]
2006-12-22 11:03                         ` Karel Zak
2006-12-22 16:52                           ` Evan Hunt
2006-12-22 12:32                       ` Ian Kent
2006-12-22 10:24                   ` Karel Zak
2006-12-22 14:50                     ` Mark Rosenstand
2006-12-22 17:38                     ` Albert Cahalan
2006-12-25 20:03                     ` Albert Cahalan
2006-12-25 22:50                       ` Bryan Henderson
2006-12-22  6:44                 ` Bryan Henderson
2006-12-22  7:52                   ` Karel Zak
2006-12-21 10:51           ` kill Alfred M. Szmidt
2006-12-21 11:39             ` kill Martin Mares
2006-12-21 15:30               ` kill Karel Zak
2006-12-21 16:50               ` kill Alfred M. Szmidt
2006-12-21 17:38                 ` kill Albert Cahalan
2006-12-22  1:37                 ` kill Ian Kent
2006-12-20 15:00     ` kill Ian Kent
2006-12-20 16:58     ` kill Albert Cahalan
2006-12-20 16:33   ` kill (was: Re: util-linux: orphan) Albert Cahalan
2006-12-20 21:12     ` Karel Zak
2006-12-21  2:32       ` Albert Cahalan
2006-12-20 16:13 ` util-linux: orphan Jan Engelhardt
2006-12-20 17:27   ` Albert Cahalan
2006-12-21 20:09     ` Jan Engelhardt

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=20061222084521.GB10592@armory.com \
    --to=ethanol@armory.com \
    --cc=P@draigbrady.com \
    --cc=acahalan@gmail.com \
    --cc=ams@gnu.org \
    --cc=bryanh@giraffe-data.com \
    --cc=kzak@redhat.com \
    --cc=util-linux-ng@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.