Sujet : Re: Useless Use Of Regexes
De : sc (at) *nospam* fiat-linux.fr (Stéphane CARPENTIER)
Groupes : comp.os.linux.miscDate : 12. Apr 2025, 12:23:14
Autres entêtes
Organisation : Mulots' Killer
Message-ID : <67fa4d22$0$28083$426a74cc@news.free.fr>
References : 1 2 3 4 5 6 7
User-Agent : slrn/pre1.0.4-9 (Linux)
Le 07-04-2025, Lawrence D'Oliveiro <
ldo@nz.invalid> a écrit :
On 06 Apr 2025 08:40:54 GMT, Stéphane CARPENTIER wrote:
>
Le 31-03-2025, Lawrence D'Oliveiro <ldo@nz.invalid> a écrit :
>
On 30 Mar 2025 22:04:45 GMT, Stéphane CARPENTIER wrote:
>
Yes, with the right option and/or with the right modification of the
command line. But it's easier and faster to just add a cat than to
find the "right" way to do it.
>
Give an example.
A lot of time I run cat to find some information in a file. And when the
file is bigger than expected, I'll just grep its output. Of course,
it's better to directly grep the file, but it's easier and faster to add
a grep at the end of the previous command than to either write directly
the right command or to go at the beginning of the line to remove the
cat and put grep instead. Mostly when the name of the file is long in a
far remote directory.
>
You do have command-line editing enabled, right? You just press the HOME
key (or CTRL/A) to go to the start of the line.
Yes. And then, I have to remove "cat". And only then can I write "grep".
Which is more difficult than just writing "| grep" at the end of the
line. So your solution is just a pedantic one to prove you can write a
theoretically better command. But it's a more difficult one and without
any advantage. Because "cat" is so fast that no human being can see the
difference in computer ressources with and without it. And it takes me
more time to think about not using cat than about adding "grep" at the
end of the line. Because it's more natural: "I have to many output, I
just reduce them" is faster and easier than to think about I have to
start at the beginning and think: "Now that I know there are to
many lines in my file, what what perfect command should I write?"
So, yes, it's a real example of a UUOC aficionado for no reason. You
prefer to avoid cat at all cost? Good for you. But telling others they
should avoid it at all cost just just because one can do better brings
you in the way of LP/DG/FF/NV/whatever.
So, you wanted an example of a good reason to use cat when it could be
avoided? I gave you one. When I want to have a result, I don't want to
be distracted to think about "the good way to do it". I want my result
as fast as possible. And I get it. Fast and easy. Your way is just
cumbersome for no advantage.
So, now, instead of telling me it's better to avoid cat at all cost,
tell me why it's better. If I can win 0.00001 second on the result,
it's useless. If I can spare 0.00001% of my processor ressources, it's
useless. So, why should I avoid cat as much as is possible? Is there a
security reason? Is there a real benefit? Or are you just like
LP/FF/NV/DG/whatever who claims things because they are written in very
old books which makes you think you know better than others?
-- Si vous avez du temps à perdre :https://scarpet42.gitlab.io