Windows 平台下的 PowerShell 与 Linux 平台的 Shell 脚本命令对比
Windows 查看帮助一般情况下,使用 Help CMD,而 Linux 一般情况下使用 CMD --help 或 man CMD。
| 说明 | 命令 | 别名 | 参数 | 示例 | 
| 删除 | rm |  | -rf | rm -rf my-dir | 
 | Remove-Item | ri, rm, rmdir, del, erase, rd | -Recurse -Force | Remove-Item -Recurse -Force my-dir | 
| 创建文件 | touch |  |  | touch my-file.txt | 
 | New-Item | ni |  | New-Item -Path ".\my-file.txt" -ItemType File,ni my-file.txt | 
| 查看端口占用 | netstat |  | -tunlp | netstat -tunlp | grep 80 | 
 | netstat |  | -ano | netstat -ano | findstr "LISTENING" | 
| 下载 | Invoke-WebRequest | iwr |  | iwr -Uri https://a.com/a.zip -OutFile b.zip | 
| 解压 | Expand-Archive |  |  | Expand-Archive -Path "file.zip" -DestinationPath "unzip" -Force | 
| 查看进程 | ps |  | -ef | ps -ef | grep cmd | 
 | Get-Process | ps, gps | -Name | Get-Process -Name cfst | Select-Object Name,Id,Path,CommandLine | 
| 查看文件内容 | cat |  |  | cat file.txt | wc -l | 
 | Get-Content | gc, cat, type |  | (cat file.txt).Length | 
| 查看列表 | ls |  | -1 | ls -1 > a.txt | 
 | Get-ChildItem | gci, ls, dir |  | Get-ChildItem | Select-Object Name | Out-File -FilePath a.txt |