https://www.it-swarm.net/ja/windows/unix%E3%81%AEuniq%E3%81%A8%E5%90%8C%E7%AD%89%E3%81%AEwindows%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%81%8B%EF%BC%9F/944513233/
windows10なら、sort.exeに/uniqueオプションがあるので、それを使うのが一番楽。
ただし必ずソートされてしまう。
C:> echo abc > hoge.txt C:> echo abc >> hoge.txt C:> echo abc >> hoge.txt C:> echo def >> hoge.txt C:> echo def >> hoge.txt C:> echo abc >> hoge.txt C:> type hoge.txt | sort /unique abc def
PowerShellを使えば柔軟性がある対応ができる。
C:> type hoge.txt | powershell -Command "$input | Get-Unique" abc def abc
エイリアスを使ってもっと短く書くと、以下のようになる。
C:> type hoge.txt | powershell -c "$input | gu"
パイプでつないで複数のコマンドレットを実行することも可能。
C:> type hoge.txt | powershell -c "$input | sort | gu"