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:
cat access.* | awk '{ print $1 }' | sort | uniq -c | sort -n
Output example:
16789 65.X.X.X
19448 65.X.X.X
1995 138.X.X.X
2407 213.X.X.X
2728 213.X.X.X
5478 188.X.X.X
6496 176.X.X.X
11332 130.X.X.X
I don't understand why these values aren't really sorted. I've also tried to remove blanks at the start of the line (sed 's/^[ ]*//g'
) and using sort -n -t" " -k1
, which doesn't change anything.
Any hint ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…