or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

file-operations.mdindex.mdlogic-math.mdmisc-utilities.mdpath-utilities.mdsystem-utilities.mdtext-processing.md
tile.json

text-processing.mddocs/

Text Processing

Comprehensive text processing utilities for filtering, searching, formatting, and transforming text data. These tools provide powerful text manipulation capabilities within the WebAssembly environment.

Capabilities

Pattern Searching

Search for patterns in text using regular expressions and fixed strings.

/**
 * Search for patterns in text
 * WebAssembly binary: dist/wasm/bin/grep
 * 
 * Usage patterns:
 * - grep [options] pattern [file...]
 * - Supports -i (case insensitive), -v (invert match), -n (line numbers)
 * - Regular expression and fixed string matching
 */

Text Display

Display portions of text files from beginning or end.

/**
 * Display first lines of files
 * WebAssembly binary: dist/wasm/bin/head
 * 
 * Usage patterns:
 * - head [options] [file...]
 * - Default shows first 10 lines
 * - Supports -n (number of lines), -c (number of bytes)
 */
/**
 * Display last lines of files
 * WebAssembly binary: dist/wasm/bin/tail
 * 
 * Usage patterns:
 * - tail [options] [file...]
 * - Default shows last 10 lines
 * - Supports -n (number of lines), -c (number of bytes)
 * - Note: tail -f (follow) not supported in WebAssembly
 */

Column Extraction

Extract specific columns or fields from text.

/**
 * Extract columns from text
 * WebAssembly binary: dist/wasm/bin/cut
 * 
 * Usage patterns:
 * - cut [options] [file...]
 * - Supports -f (fields), -c (characters), -d (delimiter)
 * - Perfect for CSV and structured text processing
 */

Text Sorting

Sort lines of text with various ordering options.

/**
 * Sort lines of text
 * WebAssembly binary: dist/wasm/bin/sort
 * 
 * Usage patterns:
 * - sort [options] [file...]
 * - Supports -n (numeric), -r (reverse), -u (unique)
 * - Custom field and key-based sorting
 */

Duplicate Removal

Report or omit repeated lines in sorted text.

/**
 * Report or omit repeated lines
 * WebAssembly binary: dist/wasm/bin/uniq
 * 
 * Usage patterns:
 * - uniq [options] [input [output]]
 * - Supports -c (count), -d (duplicates only), -u (unique only)
 * - Works on adjacent duplicate lines (use with sort)
 */

Text Counting

Count lines, words, characters, and bytes in text.

/**
 * Count lines, words, and characters
 * WebAssembly binary: dist/wasm/bin/wc
 * 
 * Usage patterns:
 * - wc [options] [file...]
 * - Supports -l (lines), -w (words), -c (characters), -m (multibyte chars)
 * - Default shows lines, words, and characters
 */

Character Translation

Translate or delete characters in text.

/**
 * Translate or delete characters
 * WebAssembly binary: dist/wasm/bin/tr
 * 
 * Usage patterns:
 * - tr [options] set1 [set2]
 * - Supports -d (delete), -s (squeeze), -c (complement)
 * - Character class support like [:alpha:], [:digit:]
 */

Text Formatting

Format text paragraphs and handle spacing.

/**
 * Format text paragraphs
 * WebAssembly binary: dist/wasm/bin/fmt
 * 
 * Usage patterns:
 * - fmt [options] [file...]
 * - Supports -w (width), -g (goal width), -s (split long lines only)
 * - Reformats paragraphs to specified width
 */
/**
 * Wrap text lines to specified width
 * WebAssembly binary: dist/wasm/bin/fold
 * 
 * Usage patterns:
 * - fold [options] [file...]
 * - Supports -w (width), -s (break at spaces), -b (count bytes)
 * - Note: File input mode has known issues
 */

Space and Tab Handling

Convert between spaces and tabs.

/**
 * Convert tabs to spaces
 * WebAssembly binary: dist/wasm/bin/expand
 * 
 * Usage patterns:
 * - expand [options] [file...]
 * - Supports -t (tab stops), custom tab spacing
 * - Note: File input mode has known issues
 */
/**
 * Convert spaces to tabs
 * WebAssembly binary: dist/wasm/bin/unexpand
 * 
 * Usage patterns:
 * - unexpand [options] [file...]
 * - Supports -t (tab stops), -a (all spaces)
 * - Inverse operation of expand
 */

Line Numbering

Add line numbers to text output.

/**
 * Number lines in text
 * WebAssembly binary: dist/wasm/bin/nl
 * 
 * Usage patterns:
 * - nl [options] [file...]
 * - Supports -b (body numbering), -n (number format), -s (separator)
 * - Note: File input mode has known issues
 */

Text Merging

Merge lines from multiple files in various ways.

/**
 * Merge lines from files side by side
 * WebAssembly binary: dist/wasm/bin/paste
 * 
 * Usage patterns:
 * - paste [options] [file...]
 * - Supports -d (delimiters), -s (serial merge)
 * - Combines corresponding lines from files
 */
/**
 * Join lines from two sorted files
 * WebAssembly binary: dist/wasm/bin/join
 * 
 * Usage patterns:
 * - join [options] file1 file2
 * - Supports -1/-2 (join fields), -t (field separator)
 * - Database-style join operation on text files
 */

File Comparison

Compare sorted files line by line.

/**
 * Compare sorted files line by line
 * WebAssembly binary: dist/wasm/bin/comm
 * 
 * Usage patterns:
 * - comm [options] file1 file2
 * - Supports -1/-2/-3 (suppress columns)
 * - Shows unique and common lines in three columns
 */

Context-Based Splitting

Split files based on context patterns.

/**
 * Split files based on context
 * WebAssembly binary: dist/wasm/bin/csplit
 * 
 * Usage patterns:
 * - csplit [options] file pattern...
 * - Supports regular expressions and line numbers
 * - Creates multiple output files based on patterns
 */

Usage Examples

Text analysis pipeline:

# Count unique words in a file (would be executed via WASM runtime)
cat document.txt | tr ' ' '\n' | sort | uniq -c | sort -nr

Data processing:

# Extract and sort email addresses from CSV
cut -d',' -f3 users.csv | sort | uniq

Text formatting:

# Format text to 80 columns
fmt -w 80 long_document.txt

Pattern matching:

# Find lines containing error patterns
grep -i "error\|warning\|fail" logfile.txt

Common Text Processing Workflows

  1. Log Analysis: grepcutsortuniq -c
  2. Data Extraction: cuttrsort
  3. Text Cleanup: trfoldfmt
  4. File Comparison: sortcomm or join
  5. Statistical Analysis: wc → custom processing

Notes

  • All text processing operates on UTF-8 encoded text
  • Utilities follow standard Unix conventions for options and behavior
  • Some utilities have known limitations in file input mode (noted above)
  • Performance characteristics may differ from native implementations
  • Output formatting matches standard Unix utility behavior