SHARE
TWEET

シェル操作課題への回答

a guest Jul 27th, 2012 645 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #シェル操作課題 (cut, sort, uniq などで集計を行う) 設問編
  2. #http://d.hatena.ne.jp/Yamashiro0217/touch/20120727/1343371036
  3.  
  4. #問1への回答
  5. Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL
  6.  
  7. #問2への回答
  8. Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Select-Object ServerName,URL
  9.  
  10. #問3への回答
  11. Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Where-Object{$_.ServerName -eq "server4"}
  12.  
  13. #問4への回答
  14. @(Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL).Count
  15.  
  16. #問5への回答
  17. Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Sort-Object -Property @{Expression="ServerName";Ascending=$true}, @{Expression={[int]$_.UserID};Ascending=$true} | Select-Object -First 5
  18.  
  19. #問6への回答
  20. @(Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Sort-Object -Unique -Property @{Expression="ServerName";Ascending=$true}, @{Expression={[int]$_.UserID};Ascending=$true}).Count
  21.  
  22. #問7への回答
  23. @(Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Sort-Object -Unique -Property UserID).Count
  24.  
  25. #問8への回答
  26. Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Group-Object URL | Sort-Object Count -Descending | Select-Object -First 1 -Property Count,Name
  27.  
  28. #問9への回答
  29. Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Sort-Object ServerName | Group-Object ServerName | Select-Object -Property Count,@{Name="xxx"; Expression = {$_.Name.Replace('server','xxx')}}
  30.  
  31. #問10への回答
  32. Import-Csv .\access.log -Header ServerName,UnixTime,UserID,URL | Select-Object UserID -Unique | Where-Object{[int]$_.UserID -ge 10} | Sort-Object {[int]$_.UserID}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top