4 ms·
Powershell on Windows does something like what you want: PS C:\Some Directory $sum = 0 PS C:\Some Directory dir | where { $_Length -gt 1MB } | %{ $sum
by noblethrasher 14y ago
Powershell on Windows does something like what you want:
PS C:\Some Directory $sum = 0
PS C:\Some Directory dir | where { $_Length -gt 1MB } | %{ $sum += $_.Length }
- mey 14y agoFirst thing I looked for when I checked the comments, was there a mention of Powershell. Powershell has the concept of passing objects (via .net clr) instead of passing strings. It sucks when trying to deal with streams of data, but fantastic for acting as script glue between various systems. One of the things I feel Microsoft really got right.
- e12e 14y agoFirst thing I checked for too. Second thing I looked for was someone pointing out that this is asking for object oriented systems (such as Smalltalk or Self). But the third thing, no one mentioned: SNOBOL. Reportedly (because I haven't used it myself) it is better than AWK for complex matching.
- ori_b 14y agoI played with SNOBOL. It may have a more powerful matching engine, but power doesn't equate to usability. Having each line followed by 3 gotos does not good UX make.
- jejones3141 14y agoIcon or its descendant Unicon might be worth a look, then.
- ori_b 14y agoMaybe. I don't think I've ever really been constrained by the power of Awk's pattern matching. I wish I could do it recursively, but that's not so much a power issue as a composability issue.
- griswald 14y agoI once read an intro to Icon written by its creator back in the 1990's. It gave a short example program to create an "index" (which lines each word appears in) from block of text, and then at the end he added some statement like "Try doing that in another language." Well, I tried in in k and it was a one-liner, maybe 1/10 the amount of text required to write the Icon program. I never looked at Icon again. It's the same story with Pike's paper. He's touting his own creation: the Sam editor. People have strong biases toward what software they want to use. Regardless of whether it is actually superior or not. It's not about power (=execution speed and amount of code). It's about fitting someone's idea of what power is. That can vary. Look at the people menitioning "Powershell" in this thread. It does not matter if it's inferior to UNIX (or just a lame copy of ksh, 20 years too late). If people like it, they'll use it. And they'll believe it is better than the alternatives.