News for hackers. Stuff that matters.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by sz4kerto on Thursday March 12, 2015 @05:16AM (#9189721)
If this can bring me a working * nix shell under Windows, I'd be extremely happy. Windows is great for everything except I have never learned PS as well as I know the * nix shells -- with this, I could enjoy the hardware and proper multi-monitor support, speed and stability (seriously) of Windows and use the * nix command line.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by cssmoo on Thursday March 12, 2015 @05:45AM (#9189811)
To be honest, and I say this with a massive cringe, after 20 years of Unix I'm more productive with PS in a couple of months! It's quite refreshingly easy to use and I genuinely had no idea how much time I was wasting on parsing streams.

Now I feel horrible for revealing my dirty secret :(

Re:Foreign Linux: Run Linux binaries on Windows without driv... by joelthelion on Thursday March 12, 2015 @06:05AM (#9189883)
What do you use for grep?

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.

Re:Foreign Linux: Run Linux binaries on Windows without driv... by cron on Thursday March 12, 2015 @06:22AM (#9189919)
`select-string` or it's alias `sst`. I find myself filtering collections of objects far more frequently then grepping lines when using powershell.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by pjc50 on Thursday March 12, 2015 @07:54AM (#9190174)
I've ended up with

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.

Re:Foreign Linux: Run Linux binaries on Windows without driv... by hug on Thursday March 12, 2015 @09:26AM (#9190592)
For the uninitiated this looks completely barbaric, but makes a whole lot of sense when you consider that PS is built around an object-based pipeline. 'Select-String' in PS doesn't actually return a string, but a 'MatchInfo' object, which contains more properties -- 'linenumber', 'context', etc, as well as the 'line' property which contains the actual matched lines as strings. The default output from any part of the pipeline is a human-readable/terminal-display-compatible representation of the object's commonly used properties, thus the truncation.

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
Re:Foreign Linux: Run Linux binaries on Windows without driv... by ygra on Thursday March 12, 2015 @12:35PM (#9191888)
You also don't technically need to go through Select-String if all you care about is the line itself:

    (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.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by bgilroy26 on Thursday March 12, 2015 @04:39PM (#9193728)
Today, I learned "Heath Robinson" is British English for "Rube Goldberg"

http://en.wikipedia.org/wiki/W._Heath_Robinson

Re:Foreign Linux: Run Linux binaries on Windows without driv... by Raesan on Thursday March 12, 2015 @08:35AM (#9190332)
You could also use either of these:

  (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.txt
Re:Foreign Linux: Run Linux binaries on Windows without driv... by rudolf0 on Thursday March 12, 2015 @09:45AM (#9190699)
Default Windows shell also has `findstr`, which works very similarly to grep. It's also quite fast.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by nailer on Thursday March 12, 2015 @07:19AM (#9190048)
I use `where` for finding stuff, but that's based on structure rather than scraping.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by swah on Thursday March 12, 2015 @11:01AM (#9191178)
Buts its not just the shell, its ps, kill, convert, ffmpeg... do you feel like you can do most stuff you do on linux in PS?
Re:Foreign Linux: Run Linux binaries on Windows without driv... by jdboyd on Thursday March 12, 2015 @03:46PM (#9193296)
Installing ffmpeg and convert on Windows (without cygwin even) is trivial.

It 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.

Re:Foreign Linux: Run Linux binaries on Windows without driv... by emodendroket on Thursday March 12, 2015 @09:30AM (#9190610)
Yeah, I think the object pipeline is very nice.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by phaemon on Thursday March 12, 2015 @09:25PM (#9195187)
You're a .Net developer who wrote a C# framework back in 2004 and consistently posts about how great Windows is and how poor Linux is.

At a wild guess I'd say that's why you're "more productive with PS in a couple of months".

Re:Foreign Linux: Run Linux binaries on Windows without driv... by ayrx on Thursday March 12, 2015 @08:24AM (#9190275)
FWIW, my current setup is Win 8.1 Pro with Hyper-V configured to startup a Linux VM on boot. My dev environment consists of cmder with an alias "dev" that ssh into the Linux VM where I have my full set of dev tools available. It's almost completely seamless since vim is my editor and I can just run that over ssh.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by rossy on Thursday March 12, 2015 @05:49AM (#9189825)
Cygwin and MSYS2 are really underrated for this. I think they do exactly what you want. I often use Bash and find to manage files on Windows.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by ryannevius on Thursday March 12, 2015 @05:39AM (#9189795)
It's not quite the same...but Git Bash for Windows[1] is an awesome substitute for the Windows command prompt.

[1] http://git-scm.com/downloads

Re:Foreign Linux: Run Linux binaries on Windows without driv... by babuskov on Thursday March 12, 2015 @06:40AM (#9189949)
AFAIK, that's actually MSYS. But since I need git anyway, I'm using exactly that, together with MinGW-w64 and it works quite well.
Re:Foreign Linux: Run Linux binaries on Windows without driv... by HaseebR7 on Thursday March 12, 2015 @06:26AM (#9189929)
you seriously need to learn PS. I'm totally lovin' it.