CRITICAL: Stop using Unix commands on PowerShell. Use these instead.
| Unix | PowerShell | Example |
|---|---|---|
head -n 50 |
Select-Object -First 50 |
pytest ... | Select-Object -First 50 |
tail -n 50 |
Select-Object -Last 50 |
pytest ... | Select-Object -Last 50 |
grep "pattern" |
Select-String "pattern" |
Get-Content file.txt | Select-String "error" |
grep -r "pattern" |
Select-String -Path "**/*.txt" -Pattern "pattern" |
Select-String -Path "**/*.py" -Pattern "TODO" |
cat file.txt |
Get-Content file.txt |
Get-Content test.log |
ls |
Get-ChildItem or ls (alias works) |
Get-ChildItem |
mkdir dir |
New-Item -ItemType Directory -Path dir |
New-Item -ItemType Directory -Path src/tests |
rm file |
Remove-Item file |
Remove-Item old.txt |
rm -r dir |
Remove-Item -Recurse -Force dir |
Remove-Item -Recurse -Force build/ |
cp file1 file2 |
Copy-Item file1 file2 |
Copy-Item src.py dest.py |
cp -r dir1 dir2 |
Copy-Item -Recurse dir1 dir2 |
Copy-Item -Recurse src/ backup/ |
find . -name "*.py" |
Get-ChildItem -Recurse -Filter "*.py" |
Get-ChildItem -Recurse -Filter "*.py" |
wc -l file |
(Get-Content file | Measure-Object -Line).Lines |
(Get-Content test.py | Measure-Object -Line).Lines |
echo "text" |
Write-Host "text" |
Write-Host "Starting tests" |
# Unix: command | head -20
# PowerShell:
command | Select-Object -First 20# Unix: command | tail -20
# PowerShell:
command | Select-Object -Last 20# Unix: command | grep "error"
# PowerShell:
command | Select-String "error"# Unix: grep -r "TODO" src/
# PowerShell:
Select-String -Path "src/**/*.py" -Pattern "TODO"# Unix: wc -l file.txt
# PowerShell:
(Get-Content file.txt | Measure-Object -Line).Lines# Unix: find . -name "*.py"
# PowerShell:
Get-ChildItem -Recurse -Filter "*.py"- Performance: PowerShell cmdlets work with .NET objects, not text streams. They're faster.
- Compatibility: Unix commands don't work on PowerShell (or work slowly via WSL).
- Cost: Every failed command wastes API credits. Using native commands reduces errors.
- Clarity: PowerShell commands are explicit and readable.
python -m pytest DivineOS/tests/unit/ -q --tb=line 2>&1 | head -150
# Error: head is not recognizedpython -m pytest DivineOS/tests/unit/ -q --tb=line 2>&1 | Select-Object -First 150
# Works perfectlyGet-Content file.txt | grep "error"
# Error: grep is not recognizedGet-Content file.txt | Select-String "error"
# Works perfectlyUnix pipes pass text:
command1 | command2 # text streamPowerShell pipes pass objects:
command1 | command2 # .NET objects with propertiesThis means PowerShell is actually MORE powerful—you can filter by object properties, not just text patterns.
From now on:
- Use
Select-Object -First Ninstead ofhead -n N - Use
Select-Object -Last Ninstead oftail -n N - Use
Select-Stringinstead ofgrep - Use
Get-ChildIteminstead offind - Use
Get-Contentinstead ofcat
This will save time, reduce errors, and use fewer credits.