PowerShellでUnix/Linuxっぽいことがしたい人へ
head
cat log.txt | select -first 10 # head
tail
cat log.txt | select -last 10
cat -Tail 10 log.txt
less
cat log.txt | more
sort, uniq
cat hoge.txt | sort | Get-Unique
grep
Select-String foo.txt -Pattern 'hoge'
sed -i
(Get-Content hoge.txt) | foreach { $_ -replace "var","foo" } | Set-Content hoge.txt
rm -r -f
Remove-Item -Recurse -Force some_dir
tar tvf
zipを展開せずファイル一覧を取得
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
foreach($sourceFile in (Get-ChildItem -filter '*.zip'))
{
[IO.Compression.ZipFile]::OpenRead($sourceFile.FullName).Entries.FullName | %{ "$sourcefile`:$_" };
$zip = [IO.Compression.ZipFile]::OpenRead($sourceFile);
$entries = $zip.Entries;
$zip.Dispose()
}
こちらに他のコマンドなどかなり詳しく記載しています。発展内容もあり。