- Top IP (awk)
$ cat logs/access_log | awk {'print $1'} | sort | uniq -c | sort -nr | head
- Top IP (perl)
$ cat logs/access_log | perl -lane 'print $F[0]' | sort | uniq -c | sort -nr | head
- Top UserAgent(awk)
$ cat logs/access_log | awk -F '"' {'print $6'} | sort | uniq -c | sort -nr | head
- Top UserAgent (perl)
$ cat logs/access_log | perl -F'"' -lane 'print $F[5]' | sort | uniq -c | sort -nr | head
- minutes access count
$ cat logs/access_log | perl -lne 'm{2017:(\d+):(\d+)} and print "$1:$2"' | sort | uniq -c | head
6559 05:06
5642 05:07
5774 05:08
5592 05:09
4010 05:10
-
%G
format problem
$ perl -MTime::Piece -E 'say Time::Piece->strptime("2014-12-30", "%Y-%m-%d")->strftime("%Y")'
2014
$ perl -MTime::Piece -E 'say Time::Piece->strptime("2014-12-30", "%Y-%m-%d")->strftime("%G")'
2015
$ perl -MTime::Piece -E 'say Time::Piece->strptime("2014-12-28", "%Y-%m-%d")->strftime("%G")'
2014
- objdump version
$ objdump -s peco | perl -lanE 'm{(go/?\d.+)} and say $1' | head -1
go/1.3/libexec
- one-liners with Mojo (http://search.cpan.org/dist/Mojolicious/lib/ojo.pm )
$ perl -Mojo -E 'say g("abehiroshi.la.coocan.jp")->dom->at("title")->text' | nkf -w
阿部寛のホームページ
$ perl -Mojo -E 'say g("abehiroshi.la.coocan.jp/top.htm")->dom("td")->[4]->text' | nkf -w
生年月日 1964年6月22日
This is first test.
これはテストです🙇
Top comments (0)