5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Grepで簡単アクセス解析

Last updated at Posted at 2016-03-22

アクセス解析ツールを使うまでもない、だいたいのアクセス数が知りたい場合のTips。
いろいろやり方はありますが、とりあえずGrepでお茶を濁す。

IISなり、Apacheなりのログファイルが手元にあるとする。

全アクセス数=行数とみなす

特定のファイルを対象とする場合は、

cat abc.log | grep -c ""

とする。""で全行が対象となる。

IISとかでは、ヘッダ情報とかが入るので、実際のアクセス数よりは多くなる。
が、あくまで、だいたい・・・の話。

特定のページへのアクセス=特定のページ名を含む行数

cat abc.log | grep -c "index.html"

フォルダ内のすべてのファイルを対象とする

基本は特定ファイルの時と何も変わらない。

全行取得。

cat *.log | grep ""

特定のページ。

cat *.log | grep "index.html"

後は、正規表現等を駆使するなりしてお好みで。

その他

ちなみに条件に正規表現を使いたい場合はegrepを使う。

cat *.log | egrep "admin+"
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?