Posted on 05/29/2015 3:37:12 AM PDT by markomalley
For me, the fact that windows doesn't have anything near as powerful as sed, awk and grep is a deal killer
By what measure is Powershell not nearly as powerful as sed, awk, and grep?
I have a 5-line bit of shellcode that does a pretty good job of it.
In the current version (V4)
$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$ht = @{}
get-childitem c:\ -Recurse -File |
Select -ExpandProperty FullName |
foreach {
$hash = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($_.FullName)))
$ht[$hash] += @($_.FullName)
}
$ht.GetEnumerator() |
Where {$_.Value.count -gt 1}
V5, which will be released with Windows 10 has a Get-FileHash command that would simplify that down to about half as many lines of code.
So, by what measure is that not nearly as powerful as sed, awk, and grep ( assuming that’s what your 5-line bit of shell code is using to find those duplicate files).
your reason 7 is actually one of the biggest reasons people won’t. Too many options just confuses and frustrates people.
99% of the people out there can do just fine...better than fine...running Mint, Ubuntu, or Fedora.
Unless you are doing console work, you really won't notice that much of a difference between the three (except that Ubuntu has these really annoying sounds in the default theme). More importantly, from the GUI, if you can run one of them, you can run any of those three.
For those with different needs or different hardware, that's when you need to start playing around with other distros...for example, Peppermint (as I mentioned above). Again, though, from the User POV, there really isn't all that much of a difference in how they run...unless you start going to the console level.
Personally, I think that Linux users are the biggest impediment to more widespread Linux use by consumers. (Try going on a Linux forum and either asking a question that's already been asked...even if it was asked 10 years ago...you'll likely get a smart-aleck "search is your friend" answer. Alternatively, you'll get 50 lines of code to input. While that works just fine for those who aren't intimidated by it, grandma may want a point-and-click solution so she can send an email to Betty)
well then, congratulations for finally making it into the 21st century! That stuff is almost as unreadable as perl. :-)
I guess now I won’t be letting the windows admin guys off anymore because the poor bastards don’t have the tools needed to do their job properly.
But now you’re in territory known as “expert friendly”. People don’t want to put that much work into deciding something. Especially because most folks don’t even know what they’re needs would be, they want to treat their computer as an appliance, they want it to be like buying a microwave.
#!/bin/sh
OUTF=rem-duplicates.sh;
echo "#! /bin/sh" > $OUTF;
find "$@" -type f -print0 | \
xargs -0 -n1 md5sum | \
sort --key=1,32 | \
uniq -w 32 -d --all-repeated=separate | \
sed -r 's/^[0-9a-f]*( )*//;s/([^a-zA-Z0-9./_-])/\\\1/g;s/(.+)/#rm \1/' >> $OUTF;
chmod a+x $OUTF; ls -l $OUTF
I'm beginning to understand why you think there's no decent command line tools in Windows. You've been snookered by the Windows admin guys!
I’m loading mine into a hash table (using the hash value as the key) as the hashes are calculated, instead of calculating all the hashes and then going back and sorting for unique values after.
So....you going to be able to beat the witch?
Thanks guys for the advice.Posting from the newly installed Ubuntu 10.04.04 on the old Acer. It works like a dream! Had a little trouble during the install as the ACER BIOS wouldn’t recognize the first USB stick that I tried (even though it recognized it in XP). Once I made the switch to another stick, it installed with no problems. Thanks again!
Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.