Now I feel horrible for revealing my dirty secret :(
Now I feel horrible for revealing my dirty secret :(
I tried using Powershell and did a few things with it, but while it is a great shell, the lack of good tools like grep prevented me from being really productive.
Select-String "pattern" -Path file.txt | ForEach-Object { Write-Output $_.Line } | Out-File t.txt
Slightly Heath Robinson, but by default PS will truncate lines to terminal width, even when writing to a file, which is a disaster for any kind of subsequent machine processing.
As an aside, you can replace the foreach with select-object for an efficiency gain:
sls "Pattern" file.txt | select -exp line | out-file t.txt (gc file.txt) -match "Pattern" | Out-File t.txt
Comparison operators that get an array as their left argument return the items where the comparison returns true. (Select-String "pattern" -Path file.txt).Line > t.txt
Select-String "Pattern" -Path file.txt | Select-Object -ExpandProperty Line > t.txt
Or equivalent to the second example but with shortcuts: sls pattern -path file.txt | select -exp line > t.txtIt looks like PowerShell even has kill (as an alias to Stop-Process) and ps (as an alias to Get-Process).
I don't like PowerShell, but I certainly wouldn't be quick to suggest that it is missing features.
At a wild guess I'd say that's why you're "more productive with PS in a couple of months".