Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.comp.os.windows-10 > #195324

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

From Maria Sophia <mariasophia@comprehension.com>
Newsgroups alt.comp.os.windows-10, alt.msdos.batch, alt.os.linux
Subject Re: PSA: How to add WSL grep to the Windwos command-line PATH
Date 2026-08-28 14:47 -0600
Organization BWH Usenet Archive (https://usenet.blueworldhosting.com)
Message-ID <116ss5s$7j2$1@nnrp.usenet.blueworldhosting.com> (permalink)
References (2 earlier) <116oqvf$19mrb$1@dont-email.me> <116puql$7ee$1@nnrp.usenet.blueworldhosting.com> <116q5cm$1pfjo$1@dont-email.me> <116qsd5$1cje$1@nnrp.usenet.blueworldhosting.com> <116rvae$2be7j$1@dont-email.me>

Cross-posted to 3 groups.

Show all headers | View raw


UPDATE

I think we're solved the AWK problem, thanks to the help from many others.
 C:\> adb shell pm list packages | awk -F: "{print \$2}" | grep shiz
       moe.shizuku.privileged.api
 C:\> adb shell pm list packages | wsl awk "{sub(/^package:/, \"\"); print}" | grep shizu
       moe.shizuku.privileged.api
 C:\> adb shell dumpsys battery | wsl tr -d '\r' | wsl awk "/level:/ {print \"Battery Level:\", \$2 \"%\"}"
       Battery Level: 93%

Previously we had to pass the entire instruction string via adb shell 
to bypass local Windows parsing, letting Android's built-in toybox/busybox awk 
handle the script natively without any WSL or .cmd wrapper gymnastics.
  C:\> adb shell "dumpsys battery | awk '/level:/ {print \"Battery Level:\", $2 \"%\"}'"

But now, with the awk.cmd set up, we can run these WSL awk examples.
 C:\> type awk.cmd
       @wsl awk %*
 C:\> adb shell pm list packages | awk -F: "{print \$2}"
       moe.shizuku.privileged.api
 C:\> adb shell pm list packages | awk "{sub(/^package:/, \"\"); print}"
       moe.shizuku.privileged.api
 C:\> adb shell dumpsys battery | tr -d '\r' | awk "/level:/ {print \"Battery Level:\", \$2 \"%\"}"
       Battery Level: 92%

Overall, we've had success based on the excellent recommendations from Paul 
(who was instrumental in adding the Rust CoreUtils to the discussion), 
but also the helpful recommendations from Herbert & Lawrence and the 
useful criticisms brought up by Frank, Carlos & vallor to flesh out ideas.

Given the recent release of Microsoft Rust Utils, it's useful to note that most of the WSL commands can be considered moot given we now have native implementations which are already included in the path for 75 utilities. 
 
Running this command garners, AFAICT, most of what this PSA is about.
 C:\> winget install Microsoft.Coreutils

Since every post should add value, here's a catalogue of what it added.

 File & Directory Operations: 
  cp, mv, rm, mkdir, rmdir, ls, ln, link, unlink, touch, pwd, basename,
  dirname, realpath, readlink

 Text Processing & Display: 
  cat, tac, head, tail, echo, printf, tee, wc, grep, sort, uniq, cut,
  paste, join, comm, fold, fmt, tr, expand, unexpand, split, csplit, nl,
  od, seq, shuf, ptx

 Checksums & Formatting: 
  md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, b2sum, 
  cksum, sum, numfmt, factor, expr

 Environment & System Info: 
  arch, nproc, uname, hostname, uptime, date, sleep, true, false, yes, 
  test, env, printenv, whoami, coreutils-manager

 File Management & Attributes: 
  df, du, stat, truncate, mktemp, pathchk, install, find, xargs

Notably missing are apparently these, which WSL2CLI.bat might be used
to add as per the original PSA post, but only after testing them.

  Text & Pattern Processing: 
   awk, sed

  Archiving & Compression: 
   tar, gzip, gunzip, bzip2, zip, unzip

  File Comparison & Patching: 
   diff, patch, cmp

  Pagination: 
   less, more

  Networking: 
   curl, wget, netcat, ssh

  Shells & Scripting: 
   bash, sh

Here are some working examples of what we've been able to accomplish.
First, elevate the shell privileges and then check elevated-shell status
 C:\> adb shell sh /storage/emulated/0/Android/data/moe.shizuku.privileged.api/start.sh
 C:\> adb shell ps -A | grep -i shizuku
       u0_a828      20618   901 6490828 151572 0                   0 S moe.shizuku.privileged.api
       shell        20817     1 5139096  88596 SyS_epoll_wait      0 S shizuku_server 

Sort the shizuku processes by order of occurrence
 C:\> adb shell ps -A | grep -i shizuku | sort -nk2
       u0_a828      20618   901 6490828 148484 0                   0 S moe.shizuku.privileged.api
       shell        20817     1 5139096  88320 SyS_epoll_wait      0 S shizuku_server

Filter package names for shizuku
 C:\> adb shell pm list packages | cut -d: -f2 | grep shiz
       moe.shizuku.privileged.api

Count total packages that the user installed themslves
 C:\> adb shell pm list packages | wc -l
       1021

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

Retrieve wi-fi ip addres
 C:\> C:\app\editor\android\scrcpy> adb shell ip addr show wlan0 | awk '/inet / {print "IP Address:", $2}'
       IP Address: 192.168.1.4/24
-- 
Usenet allows helpful experts around the world combine their experiences.

Back to alt.comp.os.windows-10 | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-26 20:08 -0600
  Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 00:05 -0600
    Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-27 07:13 +0000
      Re: PSA: How to add WSL grep to the Windwos command-line PATH "R.Wieser" <address@is.invalid> - 2026-08-27 10:02 +0200
        Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 12:14 -0600
          Re: PSA: How to add WSL grep to the Windwos command-line PATH "R.Wieser" <address@is.invalid> - 2026-08-27 22:06 +0200
            Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 20:39 -0600
              Re: PSA: How to add WSL grep to the Windwos command-line PATH "R.Wieser" <address@is.invalid> - 2026-08-28 14:35 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 14:47 -0600
          Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-27 20:19 +0000
            Re: PSA: How to add WSL grep to the Windwos command-line PATH "Carlos E. R." <robin_listas@es.invalid> - 2026-08-27 22:31 +0200
              Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 20:33 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-28 04:59 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-30 21:03 -0600
      Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-27 10:22 +0000
        Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 11:36 -0600
          Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 12:39 -0600
            Re: PSA: How to add WSL grep to the Windwos command-line PATH "Carlos E. R." <robin_listas@es.invalid> - 2026-08-27 22:20 +0200
            Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-28 18:07 +0000
              Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 14:49 -0600
          Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-27 19:11 +0000
            Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 13:21 -0600
              Re: PSA: How to add WSL grep to the Windwos command-line PATH vallor <vallor@vallor.earth> - 2026-08-27 19:59 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 21:11 -0600
                Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-28 05:00 +0000
                Re: PSA: How to add WSL grep to the Windows command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 15:27 -0600
                Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-28 22:26 +0000
                Re: PSA: How to add WSL grep to the Windows command-line PATH Hank Rogers <Hank@nospam.invalid> - 2026-08-28 17:47 -0500
                Re: PSA: How to add WSL grep to the Windows command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-29 14:35 +0000
              Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-27 20:09 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-30 20:32 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-30 20:53 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-31 05:34 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-31 12:45 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-31 09:34 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-31 22:28 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-31 21:33 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-01 07:31 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Arno Welzel <usenet@arnowelzel.de> - 2026-09-02 17:44 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Arno Welzel <usenet@arnowelzel.de> - 2026-09-02 17:41 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Paul <nospam@needed.invalid> - 2026-09-02 14:50 -0400
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Arno Welzel <usenet@arnowelzel.de> - 2026-09-02 22:00 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Richard Kettlewell <invalid@invalid.invalid> - 2026-09-02 21:16 +0100
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-09-02 23:42 +0300
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Paul <nospam@needed.invalid> - 2026-09-02 21:36 -0400
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-03 02:28 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Paul <nospam@needed.invalid> - 2026-09-02 23:18 -0400
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-03 05:03 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH "Carlos E.R." <robin_listas@es.invalid> - 2026-09-03 08:23 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-09-04 04:28 +0930
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Arno Welzel <usenet@arnowelzel.de> - 2026-09-04 18:37 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Dan Purgert <dan@djph.net> - 2026-09-02 19:51 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH "Carlos E.R." <robin_listas@es.invalid> - 2026-09-02 22:05 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Dan Purgert <dan@djph.net> - 2026-09-02 20:25 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH CDB <bellemarecd@gmail.com> - 2026-09-02 22:39 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-31 14:24 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-31 11:50 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH vallor <vallor@vallor.earth> - 2026-08-31 18:25 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-09-03 01:18 +0430
      Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 11:53 -0600
        Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-27 20:18 +0000
          Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 22:56 -0600
        Re: PSA: How to add WSL grep to the Windwos command-line PATH "Carlos E. R." <robin_listas@es.invalid> - 2026-08-27 22:30 +0200
          Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 23:12 -0600
            Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-28 06:34 +0000
              Re: PSA: How to add WSL grep to the Windows command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 02:56 -0600
                Re: PSA: How to add WSL grep to the Windows command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-29 16:40 -0600
                Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-30 02:03 +0000
                Re: PSA: How to add WSL grep to the Windows command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-29 23:05 -0600
                Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-30 06:56 +0000
                Re: PSA: How to add WSL grep to the Windows command-line PATH Paul <nospam@needed.invalid> - 2026-08-30 05:26 -0400
                Re: PSA: How to add WSL grep to the Windows command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-30 08:23 -0600
                Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-30 23:31 +0000
    Re: PSA: How to add WSL grep to the Windwos command-line PATH "J.O. Aho" <user@example.net> - 2026-09-03 08:39 +0200
  Re: PSA: How to add WSL grep to the Windwos command-line PATH Paul <nospam@needed.invalid> - 2026-08-27 04:36 -0400
    Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 10:45 -0600
      Re: PSA: How to add WSL grep to the Windwos command-line PATH Paul <nospam@needed.invalid> - 2026-08-27 14:44 -0400
        Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 12:59 -0600
          Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 13:16 -0600
        Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-27 19:41 +0000
          Re: PSA: How to add WSL grep to the Windwos command-line PATH vallor <vallor@vallor.earth> - 2026-08-27 20:03 +0000
            Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 19:18 -0600
              Re: PSA: How to add WSL grep to the Windwos command-line PATH Herbert Kleebauer <klee@unibwm.de> - 2026-08-28 12:13 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 09:51 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Herbert Kleebauer <klee@unibwm.de> - 2026-08-28 18:24 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 11:13 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Herbert Kleebauer <klee@unibwm.de> - 2026-08-28 19:36 +0200
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Frank Slootweg <this@ddress.is.invalid> - 2026-08-28 18:25 +0000
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 13:06 -0600
                Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 12:18 -0600
          Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 19:37 -0600
            Re: PSA: How to add WSL grep to the Windwos command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-28 04:28 +0000
              Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 10:46 -0600
        Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-28 01:21 +0000
          Re: PSA: How to add WSL grep to the Windows command-line PATH Paul <nospam@needed.invalid> - 2026-08-27 22:21 -0400
            Re: PSA: How to add WSL grep to the Windows command-line PATH Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-28 04:25 +0000
              Re: PSA: How to add WSL grep to the Windows command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-27 23:35 -0600
      Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-28 10:25 -0600
        Re: PSA: How to add WSL grep to the Windwos command-line PATH Paul <nospam@needed.invalid> - 2026-08-28 15:37 -0400
          Re: PSA: How to add WSL grep to the Windwos command-line PATH "Carlos E. R." <robin_listas@es.invalid> - 2026-08-29 13:16 +0200
            Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-29 16:27 -0600
  Re: PSA: How to add WSL grep to the Windwos command-line PATH Arno Welzel <usenet@arnowelzel.de> - 2026-08-30 12:58 +0200
    Re: PSA: How to add WSL grep to the Windwos command-line PATH "Kerr-Mudd, John" <admin@127.0.0.1> - 2026-08-30 12:48 +0100
      Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-30 08:23 -0600
  Re: PSA: How to add WSL grep to the Windwos command-line PATH Brian Gregory <void-invalid-dead-dontuse@email.invalid> - 2026-08-31 01:15 +0100
    Re: PSA: How to add WSL grep to the Windwos command-line PATH Maria Sophia <mariasophia@comprehension.com> - 2026-08-30 20:19 -0600

csiph-web