DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
teckl
teckl

Posted on • Updated on

One Liner Sample

  • Top IP (awk)
$ cat logs/access_log  | awk {'print $1'} | sort | uniq -c | sort -nr | head    
Enter fullscreen mode Exit fullscreen mode
  • Top IP (perl)
$ cat logs/access_log  | perl -lane 'print $F[0]' | sort | uniq -c | sort -nr | head
Enter fullscreen mode Exit fullscreen mode
  • Top UserAgent(awk)
$ cat logs/access_log  | awk -F '"' {'print $6'} | sort | uniq -c | sort -nr | head
Enter fullscreen mode Exit fullscreen mode
  • Top UserAgent (perl)
$ cat logs/access_log  | perl -F'"' -lane 'print $F[5]' | sort | uniq -c | sort -nr | head 
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode
  • %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
Enter fullscreen mode Exit fullscreen mode
  • objdump version
$ objdump -s peco | perl -lanE 'm{(go/?\d.+)} and say $1' | head -1
go/1.3/libexec
Enter fullscreen mode Exit fullscreen mode
$ 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ๆ—ฅ
Enter fullscreen mode Exit fullscreen mode

This is first test.

ใ“ใ‚Œใฏใƒ†ใ‚นใƒˆใงใ™๐Ÿ™‡

Top comments (0)

๐ŸŒš Browsing with dark mode makes you a better developer.

It's a scientific fact.