• Re: Useless Use Of Regexes

    From =?UTF-8?Q?St=C3=A9phane?= CARPENTIE@21:1/5 to All on Sun Apr 6 08:40:54 2025
    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.

    --
    Si vous avez du temps à perdre :
    https://scarpet42.gitlab.io

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Mon Apr 7 21:39:58 2025
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From c186282@21:1/5 to Lawrence D'Oliveiro on Mon Apr 7 21:00:03 2025
    On 4/7/25 5:39 PM, Lawrence D'Oliveiro wrote:
    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.


    That works OK. However 'grep' tends to be THE most
    valuable utility for finding what you want in a
    vast sea of files.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to ldo@nz.invalid on Tue Apr 8 02:05:04 2025
    In comp.os.linux.misc, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 06 Apr 2025 08:40:54 GMT, Stéphane CARPENTIER wrote:
    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.

    Very presumptious to assume emacs style line editing, isn't it?

    To go back in history, I type <ESC>k and then I'm at the start of the
    line of the most recent command. On the current line I'd type <ESC>^
    but <ESC><HOME> would work.

    But really, I don't think it is proper to care about inefficent use of
    commands at the command line. Go ahead and judge in a script or
    documentation (or an example posted to Usenet), but what people do in
    the privacy of their own shell is their business.

    Elijah
    ------
    uses <HOME>/<END> pretty much exclusively in GUI tools like browsers

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From c186282@21:1/5 to Eli the Bearded on Mon Apr 7 22:06:23 2025
    On 4/7/25 10:05 PM, Eli the Bearded wrote:
    In comp.os.linux.misc, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 06 Apr 2025 08:40:54 GMT, Stéphane CARPENTIER wrote:
    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.

    Very presumptious to assume emacs style line editing, isn't it?

    To go back in history, I type <ESC>k and then I'm at the start of the
    line of the most recent command. On the current line I'd type <ESC>^
    but <ESC><HOME> would work.

    But really, I don't think it is proper to care about inefficent use of commands at the command line. Go ahead and judge in a script or
    documentation (or an example posted to Usenet), but what people do in
    the privacy of their own shell is their business.

    Just use nano ....

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Eli the Bearded on Tue Apr 8 05:49:03 2025
    On Tue, 8 Apr 2025 02:05:04 -0000 (UTC), Eli the Bearded wrote:

    Very presumptious to assume emacs style line editing, isn't it?

    That is the usual default.

    But really, I don't think it is proper to care about inefficent use of commands at the command line.

    Don’t, then.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anssi Saari@21:1/5 to Eli the Bearded on Tue Apr 8 15:39:47 2025
    Eli the Bearded <*@eli.users.panix.com> writes:

    Very presumptious to assume emacs style line editing, isn't it?

    To go back in history, I type <ESC>k and then I'm at the start of the
    line of the most recent command. On the current line I'd type <ESC>^
    but <ESC><HOME> would work.

    The only time I've had to use vi command history editing was with some
    old version of VxWorks. It was the only kind included by default. I
    ended up teaching some colleagues on how to edit the command line, vi
    style.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Anssi Saari on Wed Apr 9 01:16:05 2025
    On Tue, 08 Apr 2025 15:39:47 +0300, Anssi Saari wrote:

    The only time I've had to use vi command history editing was with some
    old version of VxWorks. It was the only kind included by default. I
    ended up teaching some colleagues on how to edit the command line, vi
    style.

    Seems a bit dumb, having to go into insert mode every time you actually
    want to type a command.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From c186282@21:1/5 to Lawrence D'Oliveiro on Tue Apr 8 22:32:21 2025
    On 4/8/25 9:16 PM, Lawrence D'Oliveiro wrote:
    On Tue, 08 Apr 2025 15:39:47 +0300, Anssi Saari wrote:

    The only time I've had to use vi command history editing was with some
    old version of VxWorks. It was the only kind included by default. I
    ended up teaching some colleagues on how to edit the command line, vi
    style.

    Seems a bit dumb, having to go into insert mode every time you actually
    want to type a command.

    It's terrible - and was obsolete already by 1985.

    NANO folks !

    Shit, I wrote a near-equiv for DOS, in '85, in
    MASM.

    I actually DELETE/rename all the 'vi' variants so
    they can't accidentally come up .....

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anssi Saari@21:1/5 to Lawrence D'Oliveiro on Wed Apr 9 10:53:45 2025
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Seems a bit dumb, having to go into insert mode every time you actually
    want to type a command.

    Sure. Still, way better than no command history at all.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geoff Clare@21:1/5 to All on Wed Apr 9 13:26:48 2025
    c186282 wrote:

    On 4/8/25 9:16 PM, Lawrence D'Oliveiro wrote:
    On Tue, 08 Apr 2025 15:39:47 +0300, Anssi Saari wrote:

    The only time I've had to use vi command history editing was with some
    old version of VxWorks. It was the only kind included by default. I
    ended up teaching some colleagues on how to edit the command line, vi
    style.

    Seems a bit dumb, having to go into insert mode every time you actually
    want to type a command.

    That's not how it works. After the shell writes a command prompt,
    it is in insert mode, so you just type a command as normal. To edit
    the current command, or search the history, you type ESC to get out
    of insert mode and then perform the edit or search just like in vi
    (except that RETURN executes the edited command instead of moving to
    the next "line").

    It's terrible - and was obsolete already by 1985.

    It became an IEEE standard in 1992 (and ISO in 1993) for
    POSIX-conforming shells, and has remained standard to this day.
    IEEE chose not to include emacs mode, so effectively it is emacs
    mode that was treated as obsolete (in 1992).

    --
    Geoff Clare <netnews@gclare.org.uk>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?St=C3=A9phane?= CARPENTIE@21:1/5 to All on Sat Apr 12 11:23:14 2025
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?St=C3=A9phane?= CARPENTIE@21:1/5 to All on Sat Apr 12 13:07:51 2025
    Le 08-04-2025, Eli the Bearded <*@eli.users.panix.com> a écrit :
    In comp.os.linux.misc, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 06 Apr 2025 08:40:54 GMT, Stéphane CARPENTIER wrote:
    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.

    Very presumptious to assume emacs style line editing, isn't it?

    It's the same using bash in a terminal.

    But really, I don't think it is proper to care about inefficent use of commands at the command line.

    That's what I'm speaking off. In a script shared with others, it's another story. But in a terminal, the UUOC is, to my experience, always done by
    someone wanted to show off, never by someone having a good explanation.

    Go ahead and judge in a script or documentation (or an example posted
    to Usenet), but what people do in the privacy of their own shell is
    their business.

    Yes again. In a script shared with others, one needs to do the right
    thing because it's easier to understand if nothing useless appears in
    it. But in the terminal, one needs to follow his chain of thought and
    get the answer as fast as possible. And, from my experience, taking care
    of removing a cat in a previous command is always slower and more
    difficult than letting it and adding the pipe with the next command at
    the end.

    --
    Si vous avez du temps à perdre :
    https://scarpet42.gitlab.io

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to ldo@nz.invalid on Sat Apr 12 23:55:52 2025
    In comp.os.linux.misc, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Wed, 9 Apr 2025 13:26:48 +0100, Geoff Clare wrote:
    On 4/8/25 9:16 PM, Lawrence D'Oliveiro wrote:
    Seems a bit dumb, having to go into insert mode every time you
    actually want to type a command.
    That's not how it works.

    But that’s how the vi/vim editor family works. Are you saying that a command-line editor that is supposed to work like those editors doesn’t in fact, emulate them entirely faithfully?

    It is not advertised as an "entirely faithfully" emulation. In fact, the
    crappy vi-mode in early versions of bash is why I ended up preferring
    ksh, which I still use to this day when available.

    It is advertised as "vi-style command line editing interface" in recent
    bash and readline man-pages, and "a vi style in-line editor" in ksh's
    manpage. One of the key differences, which is very helpful for shell
    usage, is every line starts in insert mode.

    Other things missing from "vi-style" (or "vi style") are the : commands
    and most multiline movement commands, eg H, L, M (, ), {, }, [[, ]], and
    gg. But G does work to go to oldest item in history.

    Elijah
    ------
    overall it works better than the vi included with busybox

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Sun Apr 13 04:54:28 2025
    On 12 Apr 2025 11:23:14 GMT, Stéphane CARPENTIER wrote:

    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.

    Let’s see:
    * CTRL/A, DEL, DEL, DEL, “grep” (8 keystrokes)
    versus
    * “|grep” (5 keystrokes)

    That’s 60% more work. I suppose that’s a big chunk out of your working
    day ...

    Here’s an even more useless example:

    cat «file» | grep «pattern» | wc -l

    versus

    grep -c «pattern» «file»

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?St=C3=A9phane?= CARPENTIE@21:1/5 to All on Sun Apr 13 18:25:56 2025
    Le 13-04-2025, Lawrence D'Oliveiro <ldo@nz.invalid> a écrit :
    On 12 Apr 2025 11:23:14 GMT, Stéphane CARPENTIER wrote:

    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.

    Let’s see:
    * CTRL/A, DEL, DEL, DEL, “grep” (8 keystrokes)
    versus
    * “|grep” (5 keystrokes)

    That’s 60% more work. I suppose that’s a big chunk out of your working day ...

    Yes, because adding "|grep" comes naturally in mind when removing "cat"
    makes me think about the way to do it. So, I have to stop thinking about
    of what I want to think about the way to get it.

    But, of course, you remove the only important point because you can't
    have any reason. What does it bring me to use grep the right way? I can
    accept an added work if there is some purpose. The purpose is not about limiting my CPU ressources, the difference is invisible. The purpose
    can't be to get the answer faster, because with the added work, it takes
    me more time to have my answer.

    So why do you want to fight the UUOC? Why should I follow your advice?
    Because some pedantic moron considered it was a worthy fight to do a
    long time ago and it has been followed by parrots ever since? If so, it's
    not enough. If you can't come with a good reason for me to add an extra
    work in my workflow, I don't have any reason to follow it. And for now,
    it looks like it's only to follow pedantic morons unable to see a
    purpose on what they do.

    --
    Si vous avez du temps à perdre :
    https://scarpet42.gitlab.io

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Lawrence D'Oliveiro on Sun Apr 13 19:00:04 2025
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 04:54 this Sunday (GMT):
    On 12 Apr 2025 11:23:14 GMT, Stéphane CARPENTIER wrote:

    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.

    Let’s see:
    * CTRL/A, DEL, DEL, DEL, “grep” (8 keystrokes)
    versus
    * “|grep” (5 keystrokes)

    That’s 60% more work. I suppose that’s a big chunk out of your working day ...

    Here’s an even more useless example:

    cat «file» | grep «pattern» | wc -l

    versus

    grep -c «pattern» «file»


    You could also add a tee in between the grep and wc -l if you needed it.
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Mon Apr 14 22:39:37 2025
    On 13 Apr 2025 18:25:56 GMT, Stéphane CARPENTIER wrote:

    So why do you want to fight the UUOC?

    I don’t.

    Why should I follow your advice?

    You don’t.

    All I do is point it out. I don’t even have to say “this is uncool”, you yourself come to the conclusion that they are somehow an uncool way of
    doing things.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Anssi Saari on Sat Apr 12 06:55:34 2025
    On Wed, 09 Apr 2025 10:53:45 +0300, Anssi Saari wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Seems a bit dumb, having to go into insert mode every time you actually
    want to type a command.

    Sure. Still, way better than no command history at all.

    Luckily, that’s not a choice we non-vi/vim-users are faced with.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Geoff Clare on Sat Apr 12 06:55:05 2025
    On Wed, 9 Apr 2025 13:26:48 +0100, Geoff Clare wrote:

    On 4/8/25 9:16 PM, Lawrence D'Oliveiro wrote:

    On Tue, 08 Apr 2025 15:39:47 +0300, Anssi Saari wrote:

    The only time I've had to use vi command history editing was with
    some old version of VxWorks. It was the only kind included by
    default. I ended up teaching some colleagues on how to edit the
    command line, vi style.

    Seems a bit dumb, having to go into insert mode every time you
    actually want to type a command.

    That's not how it works.

    But that’s how the vi/vim editor family works. Are you saying that a command-line editor that is supposed to work like those editors doesn’t in fact, emulate them entirely faithfully?

    After the shell writes a command prompt, it is
    in insert mode, so you just type a command as normal. To edit the
    current command, or search the history, you type ESC to get out of
    insert mode and then perform the edit or search just like in vi (except
    that RETURN executes the edited command instead of moving to the next "line").

    Seems like a lot of unnecessary back-and-forth.

    It became an IEEE standard in 1992 (and ISO in 1993) for
    POSIX-conforming shells, and has remained standard to this day. IEEE
    chose not to include emacs mode, so effectively it is emacs mode that
    was treated as obsolete (in 1992).

    Nevertheless, that is the one that is most commonly used in *nix systems
    today.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?St=C3=A9phane?= CARPENTIE@21:1/5 to All on Thu Apr 17 19:44:55 2025
    Le 14-04-2025, Lawrence D'Oliveiro <ldo@nz.invalid> a écrit :
    On 13 Apr 2025 18:25:56 GMT, Stéphane CARPENTIER wrote:

    So why do you want to fight the UUOC?

    I don’t.

    Why should I follow your advice?

    You don’t.

    All I do is point it out. I don’t even have to say “this is uncool”, you
    yourself come to the conclusion that they are somehow an uncool way of
    doing things.

    The name UUOC, by itself, means it's uncool to do it.

    --
    Si vous avez du temps à perdre :
    https://scarpet42.gitlab.io

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Fri Apr 18 02:18:34 2025
    On 17 Apr 2025 19:44:55 GMT, Stéphane CARPENTIER wrote:

    Le 14-04-2025, Lawrence D'Oliveiro <ldo@nz.invalid> a écrit :

    On 13 Apr 2025 18:25:56 GMT, Stéphane CARPENTIER wrote:

    So why do you want to fight the UUOC?

    I don’t.

    Why should I follow your advice?

    You don’t.

    All I do is point it out. I don’t even have to say “this is uncool”, you
    yourself come to the conclusion that they are somehow an uncool way of
    doing things.

    The name UUOC, by itself, means it's uncool to do it.

    You admit it then? ;)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)