4 ms·
> Here’s a real-world example I used recently gci -rec | ? name -match zabb | ? Extension -eq .deb | % Name Of course it could be replaced with gci
by justsomehnguy 5y ago
> Here’s a real-world example I used recently
gci -rec | ? name -match zabb | ? Extension -eq .deb | % Name
Of course it could be replaced with
gci -rec | ? name -match zabb.+\.deb$ | % name
And you can filter on any property (a little excerpt):
Mode : --r--
BaseName : zabbix-release_5.0-1+bionic_all
Length : 4240
DirectoryName : /home/appliance
FullName : /home/appliance/zabbix-release_5.0-1+bionic_all.deb
Extension : .deb
Name : zabbix-release_5.0-1+bionic_all.deb
CreationTime : 5/11/2020 12:07:35 PM
> ps -ef | grep VBoxHeadless | awk '{print $2}' | xargs kill -9
Get-Process apach* | Stop-Process -Force
But 'pOwErShEll iS sO vErBoSe'
> Find Files Ending With…
gci / -re | ? name -match \.deb$
Would take longer, sure, but still the same Get-ChildItem cmdlet, no need to remember another two utilities
> $ env | grep -w PATH | tr ':' '\n'
PS /home> ( env ) -match '^PATH' -replace ':',"`n"
PATH=/opt/microsoft/powershell/7
/home/appliance/bin
/home/appliance/.local/bin
[stripped]
Again, just built-in functions, no external utilities
As usual - there is a ton of useful and nice QOL utils in *nix world, but it always feels like scratching left ear with the right hand.
- majkinetor 5y agoIt event gests way easier then that in PowerShell: > Get-Process apach* | Stop-Process -Force ps apach* | kill > gci -rec | ? name -match zabb.+\.deb$ | % name gci -rec | ? name -like zabb*.deb | % name
- justsomehnguy 5y ago> ps apach* | kill Not in Linux, because it calls native binaries there. > gci -rec | ? name -like zabb*.deb | % name Yep, even simpler. Just the original example was with regex, so I made a comparable regex example. > $ env | grep -w PATH | tr ':' '\n' Today it occurred to me what you can just use split: ( env ) -match '^PATH' -split ':'
- justsomehnguy 5y agoLinux is clearly rotting my mind. $env:PATH -split ':'