• Re: PSA: How to add WSL grep to the Windows command-line PATH

    From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.comp.os.windows-10,comp.mobile.android,alt.msdos.batch,alt.os.linux on Fri Aug 28 01:21:22 2026
    From Newsgroup: alt.os.linux

    On Thu, 27 Aug 2026 14:44:23 -0400, Paul wrote:

    Winget may span more than one repository. As if I do this:

    winget list

    I don't see any Coreutils by doing that.

    I understand what Microsoft have actually done is port the Rust-based
    remake of Coreutils, rather than the original versions written in C.

    I further understand that there are some inadvertent incompatibilities
    in the Rust-based Coreutils, which has caused Ubuntu to revert
    embracing them and go back to the original versions.

    <https://linuxiac.com/ubuntu-reverts-rust-cp-after-it-breaks-live-image-builds/>
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to alt.comp.os.windows-10,comp.mobile.android,alt.msdos.batch,alt.os.linux on Thu Aug 27 22:21:14 2026
    From Newsgroup: alt.os.linux

    On Thu, 8/27/2026 9:21 PM, Lawrence DrCOOliveiro wrote:
    On Thu, 27 Aug 2026 14:44:23 -0400, Paul wrote:

    Winget may span more than one repository. As if I do this:

    winget list

    I don't see any Coreutils by doing that.

    I understand what Microsoft have actually done is port the Rust-based
    remake of Coreutils, rather than the original versions written in C.

    I further understand that there are some inadvertent incompatibilities
    in the Rust-based Coreutils, which has caused Ubuntu to revert
    embracing them and go back to the original versions.

    <https://linuxiac.com/ubuntu-reverts-rust-cp-after-it-breaks-live-image-builds/>


    A topic like this, is a bit like explaining wine selection,
    to people who don't drink wine. You have to do your research
    and select a good vintage.

    At least with cygwin, you used to see some amount of curation,
    some amount of organization. The x86 version, I liked that and
    had installed it several times over the years. But when that
    was discontinued and an x64 version showed up, I installed
    that one day, and there was some disconcerting network activity,
    (something you never saw on the x86 version), I uninstalled it
    and that was the last Cygwin here. But other than that, at least
    you have a lineup of stuff that's all been tested and packages
    managed.

    The winget thing, I have no idea if it has any concept of
    "Repository" or it just "shops at the 7-11 and the Dollar Store".
    It seems to be downloading from Sourceforge. Working with Sourceforge
    is fine, as long as you do some amount of investigation before
    the install step. A thing like WinGet as a concept, to be shooting
    from the hip like that, the Repository used must be well maintained
    to be that trusting. And finding it downloading from Sourceforge
    does not inspire confidence. I have no idea what the folks at
    Sourceforge do, to ensure no supply side attacks. I could understand this behavior, if say, Microsoft had bought Sourceforge.

    Paul
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Fri Aug 28 05:00:55 2026
    From Newsgroup: alt.os.linux

    On Thu, 27 Aug 2026 21:11:58 -0600, Maria Sophia wrote:

    I, for one, always thought Linux, being free and rather capable,
    would outcompete Windows, but alas, there's power to corporate
    MSOffice that is undeniably sticky, to the point that Linux is
    mostly servers, not desktops.

    Microsoft seems to be moving away from rCLMicrosoft OfficerCY towards rCLMicrosoft 365rCY. And the latter lists Linux as an officially-supported platform.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to alt.comp.os.windows-10,comp.mobile.android,alt.msdos.batch,alt.os.linux on Thu Aug 27 23:35:15 2026
    From Newsgroup: alt.os.linux

    Lawrence DoOliveiro wrote:
    I understand what Microsoft have actually done is port the
    Rust-based remake of Coreutils, rather than the original versions
    written in C.

    I further understand that there are some inadvertent
    incompatibilities in the Rust-based Coreutils, which has caused
    Ubuntu to revert embracing them and go back to the original
    versions.

    <https://linuxiac.com/ubuntu-reverts-rust-cp-after-it-breaks-live-image-builds/>

    A topic like this, is a bit like explaining wine selection, to
    people who don't drink wine. You have to do your research and select
    a good vintage.

    The cp(1) command is documented to work a certain way. The C version
    does that, the Rust version doesnot.

    <https://manpages.debian.org/cp(1)>

    I only heard of the "rust coreutils" yesterday, but from what I gather, it seems that Rust Coreutils isn't "Linux technology brought to Windows" so
    much as a cross-platform reimplementation of the Unix/GNU utilities,
    written once in Rust and compiled for different operating systems. .

    Hence I would agree with anyone who logically sensibly assserts that the
    Rust CoreUtils should work the way commands are documented to work.

    Regarding someone's comment about winget and core utils, this is useful:
    winget list | grep -i coreutils
    Coreutils for Windows version 2026.6.16 Microsoft.Coreutils 2026.6.16 winget

    It appears to be brand new stuff as of June 16, 2026 (apparently).

    I like the idea of using CoreUtils in Windows because it has
    apparently a robust version of grep, but it doesn't have awk (AFAIK).
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Fri Aug 28 06:34:17 2026
    From Newsgroup: alt.os.linux

    On Thu, 27 Aug 2026 23:12:20 -0600, Maria Sophia wrote:

    Most of the adb examples on the web assume Unix tools such as grep,
    sed or awk are available in the shell. That grep/sed/awk combination
    is completely natural on the Linux side but less natural from a
    Windows command prompt.

    The noble quest is to make that completely natural on the Windows
    CLI. With Paul's CoreUtils solution & my WSL solution, we're almost
    there now.

    There are fundamental limitations on Windows which prevent that from
    ever being a mainstream solution.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Fri Aug 28 02:56:37 2026
    From Newsgroup: alt.os.linux

    Lawrence DoOliveiro wrote:

    The noble quest is to make that completely natural on the Windows
    CLI. With Paul's CoreUtils solution & my WSL solution, we're almost
    there now.

    There are fundamental limitations on Windows which prevent that from
    ever being a mainstream solution.

    Yeah. I realized that. Even with WSL & CoreUtils.
    Only the simplest of awk commands worked.

    But, the good news is most of the time, we're just using grep.

    So there's value given how easy it is to add the Rust Coreutils to Windows coupled with how easy it is to add the @wsl commands to the command line.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Fri Aug 28 15:27:32 2026
    From Newsgroup: alt.os.linux

    Lawrence D'Oliveiro wrote:
    I, for one, always thought Linux, being free and rather capable,
    would outcompete Windows, but alas, there's power to corporate
    MSOffice that is undeniably sticky, to the point that Linux is
    mostly servers, not desktops.

    Microsoft seems to be moving away from Microsoft Office towards
    Microsoft 365. And the latter lists Linux as an officially-supported platform.


    Oh wow. For decades, I wondered why Linux didn't kill Windows, where, over
    the years, I had to conclude that the MS Office suite was sticky stuff in corporate environs, and, seemingly just as web like in home computing.

    To me that was surprising, but part of the reason I guess was Microsoft
    Windows was supported and freely upgradeable for quite a long time too.

    While I use any MS Office that I still have (usually 2007, 2010 or 2016), I guess most people "upgrade" to the latest version, which is subscription nowadays.

    But looking up the Linux implementation, apparently Microsoft 365 relies heavily on a browser-based delivery model (and Progressive Web Apps) rather than a native desktop application for Linux.

    Apparently, while Microsoft officially supports accessing M365 via web
    browsers on Linux, its not the full-fledged native binaries that
    corporations tend to use (from what I gathered looking it up).

    But...

    If Linux runs MS Office "stuff" as well as Windows/macOS, at that point, there's little reason (other than inertia) to stick with Microsoft (IMHO).

    What else is keeping the general populace from using Linux over Windows?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Fri Aug 28 22:26:49 2026
    From Newsgroup: alt.os.linux

    On Fri, 28 Aug 2026 15:27:32 -0600, Maria Sophia wrote:

    For decades, I wondered why Linux didn't kill Windows, where, over
    the years, I had to conclude that the MS Office suite was sticky
    stuff in corporate environs, and, seemingly just as web like in home computing.

    Linux has taken over every market outside the desktop where Windows
    has tried to go: mobile (Windows Phone, Windows RT), living-room
    (Windows Media Center), home server (Windows Home Server), corporate
    (Windows Server), supercomputer (Windows Server HPC) -- all those
    Microsoft products were killed by Linux.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hank Rogers@Hank@nospam.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Fri Aug 28 17:47:31 2026
    From Newsgroup: alt.os.linux

    Lawrence DrCOOliveiro wrote on 8/28/2026 5:26 PM:
    On Fri, 28 Aug 2026 15:27:32 -0600, Maria Sophia wrote:

    For decades, I wondered why Linux didn't kill Windows, where, over
    the years, I had to conclude that the MS Office suite was sticky
    stuff in corporate environs, and, seemingly just as web like in home
    computing.

    Linux has taken over every market outside the desktop where Windows
    has tried to go: mobile (Windows Phone, Windows RT), living-room
    (Windows Media Center), home server (Windows Home Server), corporate
    (Windows Server), supercomputer (Windows Server HPC) -- all those
    Microsoft products were killed by Linux.


    Indeed. I am amazed that there are still 7 people left who claim to run microsoft windows. I think they are all running linux and lying about it.

    Why do they do this?




    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Frank Slootweg@this@ddress.is.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Sat Aug 29 14:35:39 2026
    From Newsgroup: alt.os.linux

    Hank Rogers <Hank@nospam.invalid> wrote:
    Lawrence D?Oliveiro wrote on 8/28/2026 5:26 PM:
    On Fri, 28 Aug 2026 15:27:32 -0600, Maria Sophia wrote:

    For decades, I wondered why Linux didn't kill Windows, where, over
    the years, I had to conclude that the MS Office suite was sticky
    stuff in corporate environs, and, seemingly just as web like in home
    computing.

    Linux has taken over every market outside the desktop where Windows
    has tried to go: mobile (Windows Phone, Windows RT), living-room
    (Windows Media Center), home server (Windows Home Server), corporate (Windows Server), supercomputer (Windows Server HPC) -- all those
    Microsoft products were killed by Linux.

    Indeed. I am amazed that there are still 7 people left who claim to run microsoft windows. I think they are all running linux and lying about it.

    Why do they do this?

    Exactly! As is clear from my 'User-Agent:' header, I'm one of those
    liars.

    I try to fob people off by using sed(1) (Can I be *more transparent!?)
    to insert lame attempts like "CYGWIN", "NT", "WOW", etc. but of course
    nobody is really falling for *that* one.

    BTW, I didn't know that apparantly Android is Linux, but macOS isn't Unix/UNIX. Never too old to learn.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Sat Aug 29 16:40:32 2026
    From Newsgroup: alt.os.linux

    Maria Sophia wrote:
    Yeah. I realized that. Even with WSL & CoreUtils.
    Only the simplest of awk commands worked.

    It's too bad the MS Rust CoreUtils don't have awk & sed though...

    However, since this PSA is meant to kick the ball forward, I should point
    out that "wsl awk" worked just fine. It did what it was supposed to do.

    Perfectly.

    The problem was Windows adb added things that we have to sed out first.

    Working examples:
    type awk.cmd
    @wsl awk %*

    adb shell dumpsys battery | tr -d '\r' | awk "/level:/ {print \"Battery Level:\", \$2 \"%\"}"
    Battery Level: 92%

    adb shell ip addr show wlan0 | awk '/inet / {print "IP Address:", $2}'
    IP Address: 192.168.1.4/24

    In summary, these two commands instantly add most of the basic Linux to Windows.
    winget install Microsoft-Coreutils
    wsl2cli.bat (assuming WSL is already installed)
    --
    I strive to add technical value, if possible, with every post to Usenet.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux on Sun Aug 30 02:03:32 2026
    From Newsgroup: alt.os.linux

    On Sat, 29 Aug 2026 16:40:32 -0600, Maria Sophia wrote:

    It's too bad the MS Rust CoreUtils don't have awk & sed though...

    perl >> awk

    sed ... I suppose it has its uses ...
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux,comp.mobile.android on Sat Aug 29 23:05:42 2026
    From Newsgroup: alt.os.linux

    Lawrence DoOliveiro wrote:
    It's too bad the MS Rust CoreUtils don't have awk & sed though...

    perl >> awk

    sed ... I suppose it has its uses ...

    Hi Lawrence,

    In interpreting your sagacious comment above, I have to openly admit that
    I'm not a coder, in that I've programmed extensively, but in IBM360
    Assembly & JCL, COBOL, Fortan IV, PL/1, etc., which, as you can tell, dates
    me back to the 1960's and 1970s' as the last time I did serious coding.

    Perl, by way of contrast, dating only to 1987, is a newcomer, to me.
    So I've never actually used Perl.

    However, if someone invests the energy to make a suggestion on Usenet,
    I likewise invest energy in at least attempting to UNDERSTNAD what they are trying to impart.

    Given your "perl >> awk" suggestion above, noting that every post to Usenet should, by design, kick the ball forward, I tested out that premise below.

    Looking up the advantages of Perl, apparently Perl users traditionally view sed as limited because Perl can do everything sed can do (via regular expression substitutions like s/find/replace/), but with the added power
    of a full programming language.

    So let's test it out...

    perl
    'perl' is not recognized as an internal or external command,
    operable program or batch file.

    winget install StrawberryPerl
    Found Strawberry Perl [StrawberryPerl.StrawberryPerl] Version 5.42.2.1
    This application is licensed to you by its owner.
    Microsoft is not responsible for, nor does it grant any licenses to,
    third-party packages. Downloading
    https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_54221_64bit/strawberry-perl-5.42.2.1-64bit.msi
    200 MB / 200 MB
    Successfully verified installer hash
    Starting package install...
    Successfully verified installer hash
    Starting package install...
    Successfully installed

    where perl
    C:\Strawberry\perl\bin\perl.exe
    Note that this is an ungodly dumb location for the default to be.
    Looking up why such an idiotic location is the default, ironically
    indicates that the Windows perl is incapable of handling spaces
    in the path correctly (e.g., "Program<space>Files"). </Irony>

    Still, in Windows cmd.exe, single quotes (') do NOT protect variables
    the way they do in Linux, so we still have the same horrors to overcome.

    WSL awk:
    adb shell dumpsys battery | tr -d '\r' | awk "/level:/ {print \"Battery Level:\", \$2 \"%\"}"
    Battery Level: 92%
    Strawberry Perl:
    We have to bypass cmd.exe's habit of mishandling single quotes.
    adb shell dumpsys battery | perl -ne "s/\r//; if (/level:\s*(\d+)/) { print 'Battery Level: $1%\n' }"
    Battery Level: $1%\n
    We also have to bypass cmd.exe's swallowing backslashes/newlines (\n)
    and we have to also protect variables from cmd.exe expansion.
    adb shell dumpsys battery | perl -ne "s/\r//; if (/level:\s*(\d+)/) { print 'Battery Level: ' . $1 . '%%\n'; }"
    Battery Level: 92%%\n
    Resulting in a working example using Perl flags (-nl) and qq{} interpolation,
    but the percent sign must be doubled to avoid Perl misinterpreting it as a hash.
    adb shell dumpsys battery | perl -nl -e "if (/level:\s*(\d+)/) { print qq{Battery Level: $1%%}; }"
    Battery Level: 92%%
    So we use Perl's hex ASCII code (\x25) to get rid of the duplicated
    percent sign to ensure a clean terminal exit.
    adb shell dumpsys battery | perl -nl -e "if (/level:\s*(\d+)/) { print qq{Battery Level: $1\x25}; }"
    Battery Level: 92%

    WSL awk:
    adb shell ip addr show wlan0 | awk '/inet / {print "IP Address:", $2}'
    IP Address: 192.168.1.4/24
    Strawberry Perl:
    We have the same problem of mishandling of quotes and newlines.
    adb shell ip addr show wlan0 | perl -ne "s/\r//; if (/inet\s+(\S+)/) { print 'IP Address: $1\n' }"
    IP Address: $1\n
    adb shell ip addr show wlan0 | perl -nl -e "if (/inet\s+(\S+)/) { print qq{IP Address: $1}; }"
    IP Address: 192.168.1.4/24

    This is apparently due to quirks in how Windows cmd.exe handles syntax compared to how Linux bash handles that same syntax.

    1. Single quotes work fine in Linux, but not in Windows
    (so we have to use double quotes instead)
    2. Unescaped dollar signs work fine in Linux, but not in Windows
    (so we have to escape the dollar signs instead)
    3. Linux adb outputs LF (\n) while Windows adb outputs CRLF (\r\n)
    (so we have to pipe it to a translate to clean up line endings)

    But once we figure those issues out, perl works as well as awk.
    adb shell getprop | tr -d '\r' | awk -F': ' '/ro\.product\.model/ {gsub(/[\[\]]/, "", $2); print "Device Model:", $2}'
    Device Model: SM-A326U
    adb shell getprop | perl -nl -e "if (/\[ro\.product\.model\]:\s*\[(.*?)\]/) { print qq{Device Model: $1}; }"
    Device Model: SM-A326U

    The question, I guess, is which is the least worst way of doing it?
    --
    Every fixed example is someone paying forward a hard-learned lesson.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux,comp.mobile.android on Sun Aug 30 06:56:55 2026
    From Newsgroup: alt.os.linux

    On Sat, 29 Aug 2026 23:05:42 -0600, Maria Sophia wrote:

    This is apparently due to quirks in how Windows cmd.exe handles
    syntax compared to how Linux bash handles that same syntax.

    Remember what I said earlier about fundamental limitations in the way
    Windows handles the command line?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux,comp.mobile.android on Sun Aug 30 05:26:13 2026
    From Newsgroup: alt.os.linux

    On Sun, 8/30/2026 2:56 AM, Lawrence DrCOOliveiro wrote:
    On Sat, 29 Aug 2026 23:05:42 -0600, Maria Sophia wrote:

    This is apparently due to quirks in how Windows cmd.exe handles
    syntax compared to how Linux bash handles that same syntax.

    Remember what I said earlier about fundamental limitations in the way
    Windows handles the command line?


    I bet you can find better ways to do it.

    In gawk, you can put a couple lines in a BEGIN {} clause
    to handle line endings in and out. When you take
    a script from Windows to Linux, you can add that to your
    script to compensate for line endings.

    BEGIN {
    RS="\r\n";
    ORS="\n";
    }

    These inline scripts, don't have to be inline.
    You can shield them in their own files. Then the
    Perl or AWK follow their own rules on quoting or whatever.
    Sometimes, it's even easier to read the code and
    make sense of it, if the code is indented and so on.

    I don't normally do AWK one-liners. I like to put them
    in files, for searching them later. I can look for file
    extension .awk and Agent Ransack content search on RS,
    to find examples of how to use RS.

    Just about every OS, has pitiful examples of escape sequences,
    and how you can "spend half a morning" figuring it out. It's
    better to just reduce the mental load by putting things in boxes.

    Paul
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux,comp.mobile.android on Sun Aug 30 08:23:36 2026
    From Newsgroup: alt.os.linux

    Paul wrote:
    Just about every OS, has pitiful examples of escape sequences,
    and how you can "spend half a morning" figuring it out. It's
    better to just reduce the mental load by putting things in boxes.

    To help move the ball forward, what I'm compiling, which may take some
    time, is a list of *useful adb commands", many of which may use awk.

    Then others can just paste the commands, without having to worry
    about line feeds, or escaping dollar signs or single vs double quotes.
    --
    Every working example is someone paying forward a hard-learned lesson.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.comp.os.windows-10,alt.msdos.batch,alt.os.linux,comp.mobile.android on Sun Aug 30 23:31:08 2026
    From Newsgroup: alt.os.linux

    On Sun, 30 Aug 2026 05:26:13 -0400, Paul wrote:

    On Sun, 8/30/2026 2:56 AM, Lawrence DrCOOliveiro wrote:

    On Sat, 29 Aug 2026 23:05:42 -0600, Maria Sophia wrote:

    This is apparently due to quirks in how Windows cmd.exe handles
    syntax compared to how Linux bash handles that same syntax.

    Remember what I said earlier about fundamental limitations in the
    way Windows handles the command line?

    I bet you can find better ways to do it.

    On Windows, you can only do this by avoiding putting things on the
    command line altogether:

    These inline scripts, don't have to be inline. You can shield them
    in their own files. Then the Perl or AWK follow their own rules on
    quoting or whatever.

    However:

    Just about every OS, has pitiful examples of escape sequences, and
    how you can "spend half a morning" figuring it out.

    Some are more pitiful than others.
    --- Synchronet 3.22a-Linux NewsLink 1.2