Last active
February 15, 2017 10:05
-
-
Save stknohg/0b43f3871462a428493d84a56921e314 to your computer and use it in GitHub Desktop.
PowerShellのSort-ObjectコマンドレットIPアドレス(V4)をソートするサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# https://orebibou.com/2015/05/linuxunixのsortコマンドでipアドレスのソートを行う/ | |
# のPowerShell版 | |
# | |
cat .\test.txt | sort (0..3|%{[ScriptBlock]::Create("[int]$`_.Split('.')[$_]")}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# version sort風(by @mutaguchi) | |
# | |
cat .\test.txt | sort {[version]$_} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
192.168.0.102 | |
192.168.0.8 | |
192.168.0.97 | |
192.168.0.68 | |
192.168.0.99 | |
192.168.0.66 | |
192.168.0.24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment