On Sun, 16 Mar 2025 23:16:55 -0400, Paul wrote :
If you want a "cat.exe" , there should be
one for you, if you want it. But that
wasn't my intention.
It turns out cat doesn't exist in PowerShell. But it does. Kind of.
It's an alias. See below for details.
All of us who came from the old school (i.e., well before the PC existed,
we were on various operating systems, one of which morphed into Linux), we
used "cat" all the time, so it was a surprise to me it's in power shell.
Thanks for letting me know. It will come in handy (if only there was awk,
sed, grep, etc.) but we all tried cygwin type stuff before WSL came about.
Then we tried WSL, and hated it (at least I hated it when I tried it).
BTW, here's an explanation of the wonderful PowerShell command you listed.
Write-Host -NoNewline "Number of Apps = " ; cat test.txt | Measure-Object -Line | Select-Object -ExpandProperty Lines
Write-Host -NoNewline "Number of Apps = ":
Write-Host is used to display text on the console.
-NoNewline prevents the cursor from moving to the next line after the
text is displayed. This allows the subsequent output to appear
on the same line.
"Number of Apps = " is the string that will be displayed.
cat test.txt:
cat is an alias for Get-Content.
It reads the contents of the file named "test.txt".
Each line of the file is treated as a separate object in the pipeline.
Measure-Object -Line:
Measure-Object with the -Line parameter counts the number of lines in the input.
Select-Object -ExpandProperty Lines:
Select-Object is used to select specific properties of an object.
-ExpandProperty Lines extracts the value of the "Lines" property from the
Measure-Object output and sends only that numerical value to the console.
Who knew all that existed? Not me. I hate powershell.
But I have to admit, it gives us the alias "cat" so that's a good thing.
Now if only there was an alias for "grep" (yes, I know, there is findstr).
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)