Tuesday, August 27, 2013

Rubyのワンライナーを使ってファイルの中で最も長い行を調べる

表題の通り、以下の処理をするワンライナー。

  • target.txtを読み込んで
  • ユニークをとって
  • 最も長い行(文字数)を調べ
  • 長い順にソートして
  • 先頭の5行を表示する

$ cat target.txt | uniq | ruby -ne 'puts sprintf("%03d %s",$_.chomp.size,$_)' | sort -r | head -5

1 comment:

Tendaxes Hobisons said...

It is not quite typical to seek out wonderful comfort services to get this kind of inexpensive price tag, however, the key enjoy field is rolling out a great deal of in the past quite a few years that at present pieces really are no longer obtainable simply for the particular well-to-do small number of. You will receive the actual innovative take a look and not having to fork out incredibly huge price ranges. Therefore you know the way celebs generally prefer to be noticed and become special? Clearly, the fact that as a result numerous carry on returning to Breitling designer watches will need to inform you exactly how beneficial they are simply. Their particular attractiveness will not impinge on most of the value or simply allure whatsoever! Right after visiting astounding fellas just like consumers sporting them http://www.hotwatchsale.co.uk, it can be impossible to not ever plan to insert designer watches selection! The watches, since clothing, are many of the most sought-after timepieces about, but not only for their looks, but also this can dependability in addition to above all, that good sense in mobility that accompany all of them. This kind of may make him or her the main number of many of the greatest artists close to. This may not be surprising after all, assigned all the dream done all through the years in to earning precise, reliable, as well as i want to in no way do not include delightful, pieces. Though ok, i will make it clear at all: Now i am in no way revealing low-cost imitations that in no way stand up a chance to go away out of mainly because true. I am talking about high end wristwatches with an exceptional likeness into the legitimate designer watches. However even though they already have lots of the attributes you are looking at within a look at, their particular unquestionable edge is actually the price tag.