Pipeline objects are typed
Every command returns objects with named properties. grep, sort, head, and tail pass through the original objects unchanged.
Real-world pipeline recipes organized by use case. Every recipe shows the one-liner command, what it does, expected output, and the typed object properties available after the pipeline completes.
find . -size +10M -type f | sort -k5 -rnRecursively finds files larger than 10 MB and sorts them by size (column 5) in descending numeric order. Useful for identifying bloat in a repository or deployment directory.
./logs/app-2026-03.log 52428800 2026-03-30 14:22./dist/bundle.js 15728640 2026-03-28 09:15./data/export.csv 11534336 2026-03-25 16:45Object properties available:
| Property | Type | Example |
|---|---|---|
Name | string | app-2026-03.log |
FullPath | string | ./logs/app-2026-03.log |
SizeBytes | long | 52428800 |
IsDirectory | bool | False |
# Programmatic access after pipeline$big = find . -size +10M -type f | sort -k5 -rn$big.SizeBytes | Measure-Object -Sum # total bytes in large files$big | Where-Object { $_.Name -like '*.log' } # filter to logs onlydu -sh * | sort -rh | head 10Shows disk usage of each item in the current directory with human-readable sizes, sorted largest first, limited to the top 10 entries.
1.2G node_modules256M dist48M logs12M src4.0K README.mdObject properties available:
| Property | Type | Example |
|---|---|---|
SizeBytes | long | 1288490188 |
Path | string | node_modules |
BashText | string | 1.2G node_modules |
$usage = du -sh * | sort -rh | head 10$usage.SizeBytes | Measure-Object -Sum # total disk usagecat app.log | grep 'ERROR' | cut -d' ' -f1-3 | sort | uniq -c | sort -rnReads a log file, filters to error lines, extracts the first three fields (typically timestamp components), then counts and ranks by frequency. Shows which time periods have the most errors.
47 2026-03-30 14:22:01 23 2026-03-30 14:22:02 12 2026-03-30 09:15:33 3 2026-03-29 23:01:17Object properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | 47 2026-03-30 14:22:01 |
ps aux | sort -k3 -rn | head 10Lists all processes, sorts by CPU percentage (column 3) in descending order, and shows the top 10 consumers.
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDyou 1234 8.2 1.4 45600 14200 pts/0 S 10:00 0:12 pwshroot 1 0.3 0.1 2400 1200 ? Ss 09:00 0:01 inityou 5678 0.1 0.5 12300 5100 pts/1 S 10:15 0:00 node server.jsObject properties available:
| Property | Type | Example |
|---|---|---|
PID | int | 1234 |
CPU | double | 8.2 |
Memory | double | 1.4 |
Command | string | pwsh |
User | string | you |
$procs = ps aux | sort -k3 -rn | head 10$procs.CPU | Measure-Object -Sum -Average # CPU stats for top consumers$procs | Where-Object { $_.CPU -gt 1.0 } # only high-CPU processesfind . -mtime -7 -type f | sortFinds all files modified in the last 7 days and sorts them alphabetically. Useful for reviewing what changed during a sprint or after a deployment.
./src/Commands.ps1./src/PsBash.psd1./tests/Commands.Tests.ps1Object properties available:
| Property | Type | Example |
|---|---|---|
Name | string | Commands.ps1 |
FullPath | string | ./src/Commands.ps1 |
SizeBytes | long | 14200 |
IsDirectory | bool | False |
$recent = find . -mtime -7 -type f | sort$recent | Where-Object { $_.Name -like '*.Tests.*' } # only test filescat api-response.json | jq '.data[] | .name'Reads a JSON file and extracts the name field from every element in the data array. Works on Windows without installing a separate jq binary.
"Alice""Bob""Charlie"Object properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | "Alice" |
# Parse the full objects for richer access$names = cat api-response.json | jq '.data[] | .name'$names.Count # number of entriesxan select name,email users.csv | xan search 'admin'Selects only the name and email columns from a CSV file, then filters to rows containing “admin”. Combines column projection with row filtering in a single pipeline.
name,emailAlice Admin,alice@example.comBob Administrator,bob@example.comObject properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | Alice Admin,alice@example.com |
cat config.yml | yq '.database.host'Extracts a nested value from a YAML configuration file. Reads the host field under the database key.
db.example.comObject properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | db.example.com |
# Chain multiple lookups$host = cat config.yml | yq '.database.host'$port = cat config.yml | yq '.database.port'echo "$host`:$port" # db.example.com:5432find . -name '*.tmp' -mtime +7 | xargs rm -fFinds .tmp files older than 7 days and passes them to rm -f for removal. The xargs bridge converts the FindEntry stream into arguments for rm.
(no output -- files are deleted silently with -f)Object properties available (before xargs):
| Property | Type | Example |
|---|---|---|
Name | string | build-cache.tmp |
FullPath | string | ./tmp/build-cache.tmp |
SizeBytes | long | 8192 |
# Preview before deletingfind . -name '*.tmp' -mtime +7# Then deletefind . -name '*.tmp' -mtime +7 | xargs rm -ffind src/ -name '*.ps1' | tar -czf scripts.tar.gz -T -Finds all PowerShell scripts under src/ and pipes the file list into tar to create a compressed archive. The -T - flag tells tar to read file names from standard input.
(no output -- archive created at scripts.tar.gz)Object properties available (from find, before tar):
| Property | Type | Example |
|---|---|---|
Name | string | PsBash.psm1 |
FullPath | string | src/PsBash.psm1 |
SizeBytes | long | 245760 |
# Verify the archive contentstar -tzf scripts.tar.gzfind . -type f | sed 's/.*\.//' | sort | uniq -c | sort -rnLists all files, strips everything before the last dot to isolate the extension, then counts and ranks by frequency. Quick way to understand a project’s file composition.
142 ps1 38 txt 25 json 12 md 7 ymlObject properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | 142 ps1 |
cat text.txt | tr ' ' '\n' | sort | uniq -c | sort -rn | head 20Splits text into one word per line, sorts alphabetically (so identical words are adjacent), counts consecutive duplicates, and ranks by frequency. The top 20 most common words appear first.
87 the 54 and 41 of 38 to 29 aObject properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | 87 the |
# Alternative: capture and use PowerShell grouping$words = cat text.txt | tr ' ' '\n'$words | Group-Object { $_.BashText.Trim() } | Sort-Object Count -Descending | Select-Object -First 20ps aux | awk '{print $1, $3, $11}' | sort -k2 -rnExtracts the user, CPU percentage, and command name columns from the process list, then sorts by CPU descending. A concise summary of who is consuming resources.
you 8.2 pwshroot 0.3 inityou 0.1 nodeObject properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | you 8.2 pwsh |
find . -name '*.ps1' | xargs sha256sum | tee checksums.txtFinds all PowerShell scripts, computes their SHA-256 checksums, writes the results to checksums.txt, and passes them through to the terminal. Useful for verifying file integrity before or after a transfer.
a1b2c3d4e5f6... ./src/PsBash.psm1f6e5d4c3b2a1... ./src/Helpers.ps11234567890ab... ./tests/PsBash.Tests.ps1Object properties available:
| Property | Type | Example |
|---|---|---|
BashText | string | a1b2c3d4e5f6... ./src/PsBash.psm1 |
The real advantage of ps-bash is that typed objects survive the entire pipeline. Assign any pipeline result to a variable and you get full property access, PowerShell filtering, and aggregation.
$files = ls -la | grep '.ps1' | sort -k5 -hThis pipeline lists files, filters to .ps1 matches, and sorts by size. Every stage preserves the original LsEntry objects.
-rw-r--r-- 1 you you 1084 Apr 2 10:30 Helpers.ps1-rw-r--r-- 1 you you 14200 Apr 2 10:28 Commands.ps1-rw-r--r-- 1 you you 245760 Apr 2 10:29 PsBash.psm1Now use those objects programmatically:
# Array of file names$files.NameHelpers.ps1Commands.ps1PsBash.psm1# Total size across all matched files$files.SizeBytes | Measure-Object -SumCount : 3Average :Sum : 261044Maximum :Minimum :Property :# PowerShell filtering on typed properties$files | Where-Object { $_.SizeBytes -gt 10000 }-rw-r--r-- 1 you you 14200 Apr 2 10:28 Commands.ps1-rw-r--r-- 1 you you 245760 Apr 2 10:29 PsBash.psm1# Group processes by user, count per user$procs = ps aux$procs | Group-Object User | Sort-Object Count -DescendingCount Name Group----- ---- ----- 42 you {PsBash.PsEntry, PsBash.PsEntry, ...} 15 root {PsBash.PsEntry, PsBash.PsEntry, ...}Pipeline objects are typed
Every command returns objects with named properties. grep, sort, head, and tail pass through the original objects unchanged.
Text in the terminal, objects in code
The terminal renders BashText so output looks like real bash. Variables hold the full typed object for programmatic use.
PowerShell cmdlets just work
Measure-Object, Where-Object, Group-Object, Select-Object, and ForEach-Object all work because the pipeline carries structured data.
No string parsing required
Replace awk '{print $5}' with .SizeBytes. Replace cut -d: -f2 with .Value. Named properties replace field extraction.
Properties available on common pipeline types:
| Pipeline Source | Type | Key Properties |
|---|---|---|
ls -la | LsEntry | Name, SizeBytes, Permissions, Owner, LastModified |
find | FindEntry | Name, FullPath, SizeBytes, IsDirectory |
ps aux | PsEntry | PID, CPU, Memory, Command, User |
grep | GrepMatch | FileName, LineNumber, Line |
du | DuEntry | SizeBytes, Path |
cat | CatLine | LineNumber, Content, FileName |
wc | WcResult | Lines, Words, Bytes, FileName |
For the full property reference, see the Object Types page.