Sort uniq IP address in from Apache log

前端 未结 5 519
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 11:32

I\'m trying to extract IP addresses from my apache log, count them, and sort them.

And for whatever reason, the sorting part is horrible.

Here is the command

5条回答
  •  臣服心动
    2020-12-12 12:24

    If sort isn't resulting as expected it's probably due to a locale issue.

    | LC_ALL=C sort -rn

    awk '{array[$1]++}END{ for (ip in array) print array[ip] " " ip}'  | LC_ALL=C sort -rn
    

    Sources sort not sorting as expected (space and locale)

    https://www.commandlinefu.com/commands/view/9744/sort-ip-by-count-quickly-with-awk-from-apache-logs

提交回复
热议问题