So the following command in Linux is to order a Nginx access.log file by those making the most requests.
'awk '{ print $1 }' access.log | uniq -c | sort -nr | more'
What it the equivalent for this command in Windows Powershell ?
Get-Content access.log | ForEach-Object { $_.split()[0] -as [IPAddress] } | Sort-Object | Select-Object -Unique -ExpandProperty IPAddressToString
or
gc access.log |%{ $_.Split()[0] -as [IPAddress] } | sort -U |%{ "$_" }
NB. your code doesn't do what you claim; you need to be sorting first, before uniq
, as it only removes consecutive duplicates, not all duplicates.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.