sed -e 's/ \+/\n/' words.txt | uniq -cOnce you commit to a programming language instead of shell, then you have various types of IO to worry about. What you want might be in an array or list, a file, a database table, an xml file, or the response from a web service. Typically, you either need to write a decent chunk of code for each of these sources, either for abstraction or for marshaling.
With LINQ, all you need is a change in the upfront handling, and you can reuse the same comprehension logic across all the different data sources. This is a pretty nice deal, all things considered.
And really, one way of looking at adding comprehensions like this to languages is to make programming in languages more like chaining together code in a shell script -- something that programming in traditional Algol-descended languages is not normally like at all.
This is not an article about trivial word counting. This an article about mathematical abstractions behind all batch data processing (unix pipes included).
Just because we already know how to count small numbers of words in bash doesn't mean we can't learn anything from this article.
sed 's/ \+/\n/' words.txt | tr A-Z a-z | sort | uniq -c
And to get the top five, you'd need another sort: sed 's/ \+/\n/' words.txt | tr A-Z a-z | sort | uniq -c | sort -gr | head -5
Where the delimiters of interest go where the space is in the sed expression. Of course, I can never remember what strange regex syntax sed uses, so I have spend 5 minutes trying to puzzle through man page.Also, it all depends on what you value; cryptic one liners definitely will get you geek cred, but working with other people not as smart as you will not be fun when having to explain and maintain code like that.
Of course, you may never have to worry about that.
So, in a way, yes, it is the same, but that is exactly the point.
curl http://weather.yahoo.com/united-states/california/san-jose-2488042/ | sed '/Current conditions/s/.*id="yw-temp">\([0-9]\+\).*/\1/'
It may be fragile, but any method of extracting data out of HTML is going to be fragile when the provider changes design or layout.A tiny bit of knowledge of grep, sed, and awk, and other simple unix text utilities such as join, comm, cut, paste, goes a long long way.
curl 'http://weather.yahooapis.com/forecastrss?w=615702&u=c' | \
xmlstarlet sel -N 'y=http://xml.weather.yahoo.com/ns/rss/1.0' \
-t -m '//y:forecast' -v '@text'
edit: corrected xml lineIt's totally possible I am missing some magical IDE feature, but if you want to do something like take a look at the 4th item in some intermediary part of a LINQ query, you're out of luck unless you can either break it up into smaller units of syntax or convert it to a loop.
I frequently hear complaints about debugging LINQ, but Visual Studio supports it well enough. Microsoft could have done a better job informing people about it.
I'm not sure how to fix this, but I am pretty sure the increasing tendency to release documentation as videos is not the answer.
On the topic of multiplatform, Mono has been working very well for many people. http://www.mono-project.com/