πŸ› οΈ Unix Executable Emulators for Windows

May 1, 2026 Β· View on GitHub

16 standalone UNIX utilities written in V β€” bridging the gap between Windows and UNIX shell environments for AI agents and developer tools.

πŸ‡§πŸ‡· Leia em portuguΓͺs

Tools Language Platform Tests


Table of Contents


Why This Exists

Windows lacks native equivalents of standard UNIX commands (ls, grep, find, etc.). While PowerShell provides aliases, they are incompatible with external programs that expect real executables on PATH.

Built for rtk

The core motivation is token economy for AI agents. When an LLM calls PowerShell cmdlets like Select-String or Get-ChildItem, the output is verbose, object-formatted, and often hundreds of lines. This wastes thousands of tokens per call β€” tokens you pay for.

These executables produce dense, UNIX-style plain-text output consumable in a single glance. Paired with rtk (AI proxy), they let agents execute CLI operations with short pipelines like:

rtk grep -n "pattern" path | rtk head -n 80
rtk findd ./src -name "*.ts" | xargs grep "TODO" | rtk head -n 200

To get the most out of this setup, use the agent system prompt provided in AGENTS_SUGGESTION_FOR_RTK.md. It enforces mandatory rtk wrappers, forbids verbose PowerShell cmdlets, and auto-excludes binary/dependency directories β€” all designed to minimize token waste.

The binaries:

  1. Work as real executables β€” callable from any shell, script, or external tool (e.g., rtk, AI agents like Codex/Gemini)
  2. Return POSIX exit codes β€” 0 for success, 1 for no match/error, 2 for usage errors
  3. Support common GNU/UNIX flags β€” progressively implementing the most-used flags
  4. Handle Windows paths β€” backslash/forward-slash normalization, PATHEXT support
  5. Auto-exclude noisy directories β€” node_modules, .git, vendor, etc. are skipped by default in recursive scans
  6. Auto-detect literal patterns β€” grep bypasses the regex engine when the pattern has no meta-characters, cutting RAM from GBs to MBs

Quick Start

Prerequisites

Build All

cd executables
.\build.bat
# or
powershell -File .\build.ps1

Build Single Tool

cd executables\exe_ls
.\build.bat

Binaries are compiled to the project root (two levels above each exe_<tool> directory). Place them in a directory on your PATH.

First Usage

ls -la .
grep -rn "TODO" ./src --include="*.v"
find . -iname "*.txt" -type f
cat -n file.txt | head -n 20
sort data.csv | uniq -c

Tool Reference

File Listing & Inspection

ls β€” List directory contents

ls [OPTIONS] [FILE...]
FlagDescription
-a, --allShow hidden files (starting with .)
-A, --almost-allLike -a but exclude . and ..
-l, --longLong listing format with permissions, size, date
-h, --human-readableHuman-readable sizes (1K, 234M, 2G) with -l
--siLike -h but use powers of 1000
-r, --reverseReverse sort order
-R, --recursiveList subdirectories recursively
-1, --one-lineOne file per line
-m, --commasComma-separated list
-SSort by file size (largest first)
-tSort by modification time (newest first)
-vNatural sort of version numbers (file2 before file10)
-XSort alphabetically by extension
-UDo not sort (directory order)
-F, --classifyAppend indicator (`*/=>@
-p, --slashAppend / to directories
--group-directories-firstGroup directories before files
-i, --inodePrint inode number
-s, --sizePrint allocated size in blocks
-n, --numeric-uid-gidNumeric user/group IDs
-g, --no-ownerLike -l but hide owner
-G, --no-groupHide group in long listing
-oLike -l but hide group
-d, --directoryList directories themselves, not contents
-Q, --quote-nameEnclose names in double quotes
-b, --escapeC-style escapes for non-graphic characters
--color=WHENColorize output (always, auto, never)
--time-style=STYLETime format (full-iso, long-iso, iso, locale)
--full-timeLike -l --time-style=full-iso
-uSort/show access time
-cSort/show status change time

pwd β€” Print working directory

pwd [OPTIONS]
FlagDescription
-LUse PWD from environment (default)
-PResolve all symlinks (stub)

Outputs forward-slash paths for UNIX compatibility.


which β€” Locate a command

which [OPTIONS] COMMAND...
FlagDescription
-a, --allPrint all matching pathnames

Searches PATH directories and respects PATHEXT on Windows.


File Content

cat β€” Concatenate and display files

cat [OPTIONS] [FILE...]
FlagDescription
-n, --numberNumber all output lines
-b, --number-nonblankNumber non-empty lines only (overrides -n)
-s, --squeeze-blankSuppress repeated empty lines
-E, --show-endsDisplay $ at end of each line
-T, --show-tabsDisplay TAB as ^I
-A, --show-allEquivalent to -vET

Reads from stdin when no file is specified or file is -.


head β€” Output first part of files

head [OPTIONS] [FILE...]
FlagDescription
-n K, --lines=KPrint first K lines (default: 10)
-c K, --bytes=KPrint first K bytes
-v, --verboseAlways print file name headers
-q, --quietNever print file name headers

tail β€” Output last part of files

tail [OPTIONS] [FILE...]
FlagDescription
-n K, --lines=KOutput last K lines (default: 10)
-f, --followOutput appended data as file grows
-s N, --sleep-interval=NSleep N seconds between follow iterations
-v, --verboseAlways print file name headers
-q, --quietNever print file name headers

Performance: Uses seek-from-end approach β€” handles multi-GB files without loading them into memory.


Search & Filter

grep β€” Search for patterns in files

grep [OPTIONS] PATTERN [FILE...]
FlagDescription
-i, --ignore-caseCase-insensitive matching
-v, --invert-matchSelect non-matching lines
-n, --line-numberPrint line numbers
-c, --countPrint only match count per file
-l, --files-with-matchesPrint only filenames with matches
-L, --files-without-matchesPrint only filenames without matches
-r, -R, --recursiveSearch directories recursively
-w, --word-regexpMatch whole words only
-x, --line-regexpMatch whole lines only
-F, --fixed-stringsTreat pattern as literal string
-o, --only-matchingShow only the matched part of lines
-H, --with-filenamePrint filename with output
-h, --no-filenameSuppress filename prefix
-A N, --after-context=NPrint N lines after each match
-B N, --before-context=NPrint N lines before each match
-C N, --context=NPrint N lines of context (before + after)
-m N, --max-count=NStop after N matches per file
-q, --quietSuppress all output
-s, --silentSuppress error messages
--color=WHENColorize matches (always, auto, never)
--exclude=GLOBSkip files matching GLOB
--exclude-dir=DIRSkip directories matching DIR
--include=GLOBSearch only files matching GLOB

Performance: Auto-detects literal patterns to bypass the regex engine, circular buffer for context lines (O(1) vs O(n) for before-context), auto-excludes node_modules/.git/vendor/etc in recursive scans, iterative BFS-based directory traversal.


find β€” Search for files in directory hierarchy

find [PATH...] [OPTIONS]
FlagDescription
-name PATTERNMatch filename (case-sensitive glob)
-iname PATTERNMatch filename (case-insensitive glob)
-type TYPEFilter by type (f = file, d = directory)
-emptyMatch empty files/directories
-maxdepth NDescend at most N levels
-deleteDelete matched files
-o, -orOR operator between filter groups

Supports combining multiple filters with -o (OR logic). Glob patterns use * and ?.

Performance: Regex patterns are pre-compiled once at startup, not per-file.


sort β€” Sort lines of text files

sort [OPTIONS] [FILE...]
FlagDescription
-r, --reverseReverse sort order
-n, --numeric-sortCompare by numerical value
-u, --uniqueOutput only unique lines

uniq β€” Filter adjacent duplicate lines

uniq [OPTIONS] [INPUT [OUTPUT]]
FlagDescription
-c, --countPrefix lines by occurrence count
-d, --repeatedOnly print duplicate lines
-u, --uniqueOnly print unique lines
-i, --ignore-caseCase-insensitive comparison

File Operations

cp β€” Copy files and directories

cp [OPTIONS] SOURCE... DEST
FlagDescription
-r, -R, --recursiveCopy directories recursively
-f, --forceForce overwrite
-i, --interactivePrompt before overwrite
-n, --no-clobberDo not overwrite existing files
-v, --verboseExplain what is being done

mv β€” Move/rename files

mv [OPTIONS] SOURCE... DEST
FlagDescription
-f, --forceDo not prompt before overwriting
-i, --interactivePrompt before overwrite
-n, --no-clobberDo not overwrite existing files
-v, --verboseExplain what is being done

rm β€” Remove files and directories

rm [OPTIONS] FILE...
FlagDescription
-r, -R, --recursiveRemove directories recursively
-f, --forceIgnore nonexistent files, never prompt
-i, --interactivePrompt before every removal
-v, --verboseExplain what is being done
-d, --dirRemove empty directories

mkdir β€” Create directories

mkdir [OPTIONS] DIRECTORY...
FlagDescription
-p, --parentsCreate parent directories as needed
-v, --verbosePrint message for each created directory

touch β€” Update file timestamps

touch [OPTIONS] FILE...
FlagDescription
-c, --no-createDo not create any files
-aChange only the access time
-mChange only the modification time

Utilities

xargs β€” Build and execute commands from stdin

xargs [OPTIONS] [COMMAND [ARGS...]]
FlagDescription
-0, --nullInput items separated by NUL (for find -print0)
-I REPLACEReplace REPLACE in args with each input item
-n MAXUse at most MAX arguments per command
-t, --verbosePrint commands before execution
-r, --no-run-if-emptyDon't run command if stdin is empty

Examples:

find . -name "*.txt" | xargs grep "TODO"
find . -print0 | xargs -0 wc -l
echo file1 file2 | xargs -I {} cp {} /backup/
ls *.log | xargs -n 2 echo "Batch:"

Argument Policy

For any flag that is not yet implemented, the tools return a standardized error message:

TODO (UNIX WINDOWS): THIS ARGUMENT HAS NOT YET BEEN IMPLEMENTED.
USE AN ALTERNATIVE METHOD, AS THE "ls" COMMAND DOES NOT YET HAVE THIS ARGUMENT "-la".

This message is designed for AI agents to understand and use alternative approaches.


Testing

Each tool has integration tests in its tests/ directory:

# Run tests for a specific tool
cd executables\exe_grep
v test tests/

# Run all tests
Get-ChildItem -Directory exe_* | ForEach-Object {
    Write-Host "Testing $($_.Name)..."
    Push-Location $_.FullName
    v test tests/
    Pop-Location
}

Tests use os.execute() to run the compiled binary and verify exit codes and output. New features and optimizations require new tests β€” see AGENTS.md for the full testing policy.


Architecture

executables/
β”œβ”€β”€ AGENTS.MD          # Agent-facing documentation & testing policy
β”œβ”€β”€ README.md          # This file
β”œβ”€β”€ README.pt-br.md    # Brazilian Portuguese version
β”œβ”€β”€ build.ps1          # Build all tools
β”œβ”€β”€ build.bat          # Wrapper for build.ps1
β”œβ”€β”€ exe_ls/            # Each tool in its own directory
β”‚   β”œβ”€β”€ main.v         # Entry point & argument parsing
β”‚   β”œβ”€β”€ lister.v       # Core logic (directory listing)
β”‚   β”œβ”€β”€ filedata.v     # Data structures
β”‚   β”œβ”€β”€ options.v      # Options struct
β”‚   β”œβ”€β”€ utils.v        # Utility functions
β”‚   β”œβ”€β”€ build.bat      # Individual build script
β”‚   └── tests/
β”‚       └── ls_test.v  # Integration tests
β”œβ”€β”€ exe_grep/
β”‚   β”œβ”€β”€ main.v
β”‚   β”œβ”€β”€ matcher.v      # Regex/fixed-string matching engine
β”‚   β”œβ”€β”€ processor.v    # File processing & output
β”‚   β”œβ”€β”€ filters.v      # --exclude/--include handling
β”‚   β”œβ”€β”€ options.v
β”‚   └── tests/
β”‚       β”œβ”€β”€ grep_test.v
β”‚       β”œβ”€β”€ context_test.v
β”‚       β”œβ”€β”€ exclude_test.v
β”‚       β”œβ”€β”€ literal_test.v
β”‚       └── autoexclude_test.v
└── ...                # 14 more tools following the same pattern

Conventions

  • Directory naming: exe_<command> (e.g., exe_ls, exe_grep)
  • Build output: Each build.bat compiles to ../../<command>.exe (the bin/ root)
  • Build flags: All builds use -prod for optimized release binaries
  • Module: All files use module main
  • Options: Parsed with V's flag module, stored in an Options struct

Building

Single Tool

cd executables\exe_ls
v -prod -o "..\..\ls.exe" .

All Tools

cd executables
.\build.ps1

Development (fast, no optimizations)

cd executables\exe_ls
v -o "..\..\ls.exe" .

RTK on Windows β€” Agent Prompt Template

To get the most out of these tools with rtk, use the agent system prompt provided in AGENTS_SUGGESTION_FOR_RTK.md. It enforces:

  • MANDATORY use of rtk wrappers for CLI operations on Windows
  • FORBIDDEN use of native PowerShell cmdlets (Select-String, Get-Content, Get-ChildItem) for file/text operations
  • Short UNIX-style pipelines with rtk grep ... | rtk head ...
  • Targeted paths/extensions over broad recursive scans from .
  • findd | xargs grep to narrow by directory and file type before running grep
  • Auto-exclusion of binary files, node_modules, .git, build/, dist/, etc.
  • Auto-exclusion of binary extensions: *.exe, *.dll, *.sqlite, *.png, *.pdf, *.zip, etc.

See the file for the full ready-to-copy prompt and examples.

Why this matters: PowerShell cmdlets produce verbose, object-formatted output that wastes thousands of AI tokens per call. These UNIX-style tools output dense plain text β€” a single rtk grep ... | rtk head -n 80 can replace a 200-line PowerShell output with 3-5 lines the LLM can consume instantly.


License

Internal tooling β€” part of the rtk ecosystem.