[H-GEN] any faster way?
Anthony Towns
aj at azure.humbug.org.au
Tue Jun 16 09:16:52 EDT 1998
[moved back to general -- more thorough discussion on what works and why
should be on code-review, or possibly chat, as Ben says, but I'm just
going to make some random generalisations that apply to Unix admin'ing
in general, IMAO, so...]
On Tue, Jun 16, 1998 at 09:16:40PM +1000, Ben Fowler wrote:
> > I've got database (read 'directory') of around 4000 files that
> > I'm trying to tidy up (remove files with <5 lines) and see which files
> > I've deleted since I created my master database list. This is what I
> > came up with, but the find is s-l-o-w. Is there another faster
> > approach?
> Call me stupid, but I'd be inclined to write a small C program to do the
> same job. Methinks that about 100-150 lines of quick-and dirty C might do
> the trick?
In general, it's best to try a shell script first. They're easier to
write, and you can generally do funkier things with them once you
know what you're doing.
For example, to get a list of the 100 most common words in a document,
you can do:
cat $DOC | tr ' \t\n' | tr 'A-Z' 'a-z' |
grep -v '[a-z]' | sort | uniq -c | sort -n | tail -100
You're encouraged to try writing it in C -- and you'll probably do a
better job of it than the above, I've no doubt there's things I didn't
bother considering -- but you're not going to get anything anywhere near
as simple as that.
Shell scripts are wonderful. Shell scripts are delightful. Shell scripts
rock the world.
Of course, you have to be careful when you use them -- things like
"while" and "for" loops are incredibly slow, and running programs
when you don't have to, and looking at the disk more often than you
need too are also painful.
Cheers,
aj
--
Anthony Towns <aj at humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. PGP encrypted mail preferred.
``It's not a vision, or a fear. It's just a thought.''
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 434 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/19980616/79456397/attachment.sig>
More information about the General
mailing list