よく使われると思われるコマンドの比較表・対応表を作成しました。~
対象となるのは、Linux, コマンドプロンプト, PowerShellの3つを記述しています。
No | セクション | Linux | コマンドプロンプト | PowerShell |
1 | ファイル・ディレクトリ関連 | ls, dir | dir | Get-ChildItem |
2 | ls -1 | dir /b | Get-ChildItem -Name | |
3 | ls -F | grep / | dir /ad | Get-ChildItem | Where-Object {$_.Attribute -eq "Directory"} Get-ChildItem | Where-Object { $_.PSIsContainer } | |
4 | ls -ltr | dir /od | Get-ChildItem | Sort-Object LastWriteTime | |
5 | ls -lt | dir /o-d | Get-ChildItem | Sort-Object LastWriteTime -Descending | |
6 | cat | type | Get-Content | |
7 | cp | copy | Copy-Item | |
8 | cp -r | xcopy robocopy | Copy-Item -Recurse | |
9 | rm | del erase | Remove-Item | |
10 | mv | move | Move-Item | |
11 | mv | ren | Rename-Item | |
12 | find . | dir /b /s | Get-ChildItem -Recurse -Name | |
13 | wc -l | find /c /v "" | (Get-Content 対象ファイル名 | Measure-Object).Count | |
14 | pwd | cd chdir | Get-Location | |
15 | mkdir | mk mkdir | New-Item -ItemType Directory | |
16 | cd | cd chdir | Set-Location | |
17 | rmdir | rd rmdir | Remove-Item | |
18 | diff | fc | Compare-Object (Get-Content ファイル名) (Get-Content ファイル名) | |
19 | rsync | robocopy | ← | |
20 | touch | type null > ファイル名 | New-item -ItemType File ファイル名 | |
21 | touch | copy ファイル名 + | (Get-Item ファイル名).LastWriteTime = (Get-Date) | |
22 | プロセス | ps | tasklist | Get-Process |
23 | kill | taskkill | Stop-Process | |
24 | killall | taskkill /im | Get-Process | Where-Object ($_.ProcessName -eq "プロセス名") | % { Stop-Process $_.Id } | |
25 | 文字列操作 | grep | findstr | Select-String -CaseSensitive |
26 | grep -i | findstr /i | Select-String | |
27 | sort | sort | Get-Content ファイル名 | Sort-Object | |
28 | sort | uniq | - | Get-Content ファイル名 | Sort-Object | Get-Unique | |
29 | tr | - | 文字列.Replace("置換前文字列", "置換後文字列") | |
30 | 日付・時刻 | date '+%Y/%m/%d' | date /t echo %DATE% | Get-Date -Format yyyy/MM/dd |
31 | date '+%T' | time /t echo %TIME% | Get-Date -Format hh:mm:ss | |
32 | システム | uname -a | ver winver systeminfo | findstr /b "OS" | [Environment]::OSVersion |
33 | cat /proc/cpuinfo | systeminfo | Get-WMIObject Win32_Processor | Format-List | |
34 | cat /proc/meminfo | systeminfo | Get-WMIObject Win32_PhysicalMemory | Format-List | |
35 | sar | logman | - | |
36 | vmstat | logman | - | |
37 | iostat | logman | - | |
38 | man | コマンド /? | Get-Help コマンドレット | |
39 | hostname | hostname | ← | |
40 | top | taskmgr | ← | |
41 | 環境・シェル関連 | exit | exit | Exit-PSSession |
42 | env | set | Get-ChildItem env: | |
43 | printenv | set | Get-ChildItem env: | |
44 | echo | echo | Write-Host | |
45 | clear | cls | Clear-Host | |
46 | alias | doskey 別名=コマンド | Set-Alias New-Alias | |
47 | history | - | Get-History | |
48 | $RANDOM | %RANDOM% | Get-Random | |
49 | which | where | Get-Command | |
50 | $? | %ERRORLEVEL% | $lastexitcode | |
51 | $$ | - | $PID | |
52 | ユーザ | who -u | query user query user /server:ホスト名 | ← |
53 | who am i | whoami | ← | |
54 | ネットワーク | ifconfig -a | ipconfig /a | ← |
55 | netstat | netstat | ← | |
56 | arp | arp | ← | |
57 | ping | ping | ← | |
58 | traceroute | tracert | ← | |
59 | nslookup | nslookup | ← | |
60 | その他 | /dev/null | NUL | $NULL |
61 | sleep | timeout /t 秒 /nobreak > nul | Start-Sleep |