タグ

awkに関するescape_artistのブックマーク (2)

  • N 行目から M 行目までを表示 - 日本 GNU AWK ユーザー会 0.2

    http://d.hatena.ne.jp/yanma_4/20080330/1206803656 ここに書かれていた FNR >= N && FNR <= M という書き方と FNR == N, FNR == M という書き方とどちらが高速なのかが風呂の中で気になったので調べてみました。 こういうのはサンプルが意地悪な方がハッキリします。 頭の中では、awk は '&&' の処理が遅いというのと、前者は式を 2 つ常に評価しなければいけないので遅く、後者は (結果的に '&&' な処理になっているかもしれないが awk をパースしているわけではないので) 式の評価が片側だけなので高速なのではないかという勝手な推論を立てているわけですが、実証してみないと分からない、いやスクリプト言語ならやった方が早いので、やってみました。 $ seq 10000000 > test.txt $ time

    N 行目から M 行目までを表示 - 日本 GNU AWK ユーザー会 0.2
  • awk is a beautiful tool

    AWK is a very powerful programming language that we can use on the command-line for advanced text processing. I’d like to provide a guide so you can get started using it. I’ll be covering the basics of AWK (named after Alfred Aho, Peter Weinberger, and Brian Kernighan) and provide some useful examples. Tutorial To best introduce awk I’d like to start with a practical example. Most of the applicati

  • 1