bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A new utility: trv


From: Giuliano Colla
Subject: Re: A new utility: trv
Date: Wed, 05 Jan 2005 21:17:40 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.6) Gecko/20040116

I don't claim that trv is a revolution in computer art, deserving that my portrait be hung in the hall of fame among Ritchie, Thompson, Stevens and Thorvald. It's just handy.

Of course it can be implemented with a bit of shell scripting. Actually *it is* implemented as a quite trivial shell script. You just prepend #!/bin/sh to your "for x in `find . -type d`.. etc. you save it as "trv", make it executable, and you've got "trv". I've implemented differently, because I noticed that sometimes "find ." gets confused when crossing filesystems, but it's just a matter of personal taste.

But the same holds true for a lot of other utilities: In the RedHat install scripts you have "service" which saves you typing "/etc/rc.d/init.d/"; "vdir" is nothing but an "ls -l -b". And why provide "ls" when "stat * | grep File:" (or a more sophisticated sed filtering) provides you the same information? You don't need "vim" when you've got "vi". Anything done by vim can be done with vi, with some extra typing. You don't need Emacs when you've got vim. It's just a matter of extra typing and a bit of scripting. The problem is that if you save extra typing and scripting you save time and errors.

The Unix principles, set by those who rightfully deserve a portrait in the hall of fame, are to provide small pieces which combined together perform powerful actions, to never duplicate efforts, and to provide as concise commands as possible, to save typing and typing errors.

That's the value of "trv". A small tool which provides recursion for whatever command you may think of, be it an existing utility or a shell script. It's concise, doesn't force you to add an -R option to whatever script you think, you may concentrate of what you're doing. It's not the implementation that matters, it's the concept. Which, btw, isn't mine. One more reason not to have my portrait in the hall of fame.

Cheers,

Giuliano

p.s. The versions of find I have around on RHEL (findutils 4.1.7) doesn't support the -execdir action. When did it pop up?

Alfred M. Szmidt ha scritto:

  Once  findutils does the deacent thing...

  cat >> $HOME/.env <<EOF
  trv() {       
           find . -type d -execdir "$1" \;
  }
  EOF

Don't see why this would be decent, since it can already be done with
a bit of shell as I already pointed out.  What would happen if you do:

find . -type f -execdir "echo {}" \;

for example?

Cheers!



--
Ing. Giuliano Colla
Direttore Tecnico
Copeca srl
Via del Fonditore 3/E
Bologna (Zona Industriale Roveri)

Tel. +39 051 53.46.92 - +39 335 610.43.35
Fax +39 051 53.49.89






reply via email to

[Prev in Thread] Current Thread [Next in Thread]