[Novalug] ls -d
James Ewing Cottrell III
jecottrell3@comcast.net
Wed Dec 14 03:22:49 EST 2016
On 12/13/2016 9:42 AM, Rich Kulawiec via Novalug wrote:
> On Tue, Oct 25, 2016 at 02:08:16PM -0400, James Ewing Cottrell III via Novalug wrote:
>> Why are you Arguing the Case for Inefficiency?
>
> Because I'm a seasoned professional who grasps the concept that fretting
> about optimization in a script that will, *by design*, be run once and then
> thrown away is ridiculous.
Software Never Dies. Neither do Concepts. People STILL quote ":wq" as
the way to Exit VI, rather than ZZ (or :x) which will Avoid Writing when
need be.
You never know when a Throwaway Script will be used by are copied by
someone and used wh
> Because -- having written software that had life-or-death consequences --
> I understand that there's a place for rigorous, bordering-on-fanatic
> correctness. I also understand that an introductory explanation to
> the basics of shell scripting is nowhere near that place.
It's a question of Scope. System administrators use find a lot, often
with -exec. Learning to replace the ';' with '+' is Trivial.
> Because if I actually had to turn this into something efficient and
> robust and durable I wouldn't be using find(1) at all.
I don't see why Do you think calling some kind or File Tree Walk library
call is going to be that much better? Piping the output of find or
running it as a subprocess is quite efficient and allows paralleism.
> Because I work on a lot of different Linux and Unix systems, and some
> of them have versions of find(1) that don't support this construct.
> Portability is much more important to me than efficiency.
There is No Issue of Portability here. Everywhere has the new find -exec
with the + character. More to the point, Everywhere You Want To Be.
Praying to the Gods of Portability keeps alive the abominations of
if [ x$variable = xvalue ]
Sorry...Done...Consigned to the Scrap Heap of the Wrong Side of History.
> Because -- without exception -- every programmer I've ever encountered
> who obsessed about efficiency was an absolutely terrible programmer,
> so I try very hard not to be one of them.
Efficiency isn't the Evil....Premature Efficiency is.
It's a Good Habit to get into, and you don't have to think about whether
it's a Small Search or a Big Search.
You have to remember Two Things and decide When to use Each.
I only have to remember One, and it is Always Better, whether it Makes a
Difference or Not.
> ---rsk
JIM
P.S. Go run the following commands:
time find /etc -type f -exec grep -q . {} \;
time find /etc -type f -exec grep -q . {} \+
Then do the same for /usr/share
I get an entire minute for the first case and just 0.2 seconds for the
second. That's a factor of 300. Ignore it At Your Own Peril.
More information about the Novalug
mailing list