Skip to content

POSIX Shell and Coreutils

Ved Gupta edited this page Oct 24, 2026 · 3 revisions

POSIX Shell & Coreutils Reference (v0.2.0)

@innovatorved/code-lab includes a pure-JavaScript POSIX shell AST interpreter and 67 UNIX coreutils running directly against the in-memory Virtual Filesystem (VFS).


1. Shell Syntax & Operators

Pipelines (|)

Chain stdout of one command directly into stdin of the next:

cat balancer.js | grep -n "class" | head -n 5
find . -name "*.js" | wc -l
cat access.log | grep " 500 " | awk '{print $1}' | sort | uniq -c

Redirection (>, >>, <, <<<, <<EOF, 2>&1, &>)

Redirect command output to or from virtual files:

# Overwrite file
echo "hello world" > out.txt

# Append to file
echo "another line" >> out.txt

# Redirect stderr to stdout
node broken.js > log.txt 2>&1

# Redirect all streams
cmd &> combined.log

# Input redirection & here-string
wc -l < data.json
jq '.status' <<< '{"status":"ok"}'

Real C++20 Compilation & WASI Execution (g++, clang++, c++, ./a.out)

Compile and execute C++17 / C++20 / C++23 source files directly in the terminal:

# Compile C++20 source to a WebAssembly WASI binary in VFS
g++ -std=c++20 -O2 main.cpp -o app

# Run the compiled WASI binary with CLI arguments and stdin
./app --threads 4 < input.txt

Public GitHub Repository Cloning (git clone)

Clone any public GitHub repository into /workspace with real-time progress streaming:

git clone https://github.com/owner/repo
# or shorthand with branch selection
git clone owner/repo --branch main

Background Execution (&) & Process Table

Keep long-running servers or jobs listening in the background:

# Start an HTTP server in the background
node server.js &
# or
bun run server.ts &

# View active processes and port bindings
ps
ports

# Load test the server and inject chaos rules
hey -n 100 -c 10 http://localhost:3000/api
chaos latency 3000 150ms

# Terminate process by PID
kill 1

2. Supported Coreutils Reference (67 Commands)

Category Commands Description
File & Directory (26) ls, cat, head, tail, wc, cp, mv, rm, mkdir, rmdir, touch, ln, pwd, cd, find, tree, stat, file, du, df, chmod, chown, mktemp, basename, dirname, realpath Full POSIX filesystem navigation, inspection, permissions, symlinks, and directory tree utilities.
Text & Data Processing (16) grep, sed, awk, sort, uniq, cut, tr, tee, xargs, diff, jq, xxd, hexdump, base64, md5sum, sha256sum Regex search, stream editing, JSON querying (jq), hex dumps, and cryptographic digests.
Networking, Load Testing, Chaos & Databases (16) curl, hey (ab, wrk), chaos, sqlite3, redis-cli, nc, ping, dig, nslookup, lsof, netstat, ss, ps, top, kill, jobs, fg, bg Loopback HTTP client (curl), HTTP load generator (hey/ab/wrk), fault injection (chaos), interactive sqlite3 & redis-cli, and process/port inspection.
Developer Toolchains & Archives (9) node, bun, npm, pnpm, npx, bunx, tsc, g++, clang++, c++, git, serve, tar, gzip, gunzip Node.js v22, Bun v1.1, TypeScript compiler (tsc), Clang/WASI C++20 compiler (g++/clang++/c++) + ./a.out execution, Git (init, status, add, commit, log, diff, branch, checkout, clone), and built-in ESM dev server (serve).

Clone this wiki locally