Complete command reference for MXCMD built-ins, file tools, list operations, debug helpers, and regex processing.
This page is organized as a practical reference: each command includes a short purpose statement, syntax, and example where useful. Numeric return conventions generally follow shell behavior: 0 indicates success/true, non-zero indicates failure/false.
cmd "build.mxcmd"
tokenize "build.mxcmd"
visual "build.mxcmd" "build_ast.html"
regex_replace "[^a-zA-Z0-9]" "_" value
execExecute an external shell command and return its output as text. This is the primary bridge between MXCMD and system shell tools.
exec "ls"
files = $(exec "ls | sort")
random_shaderApply a random shader effect in console GUI mode.
random_shader
default_shaderReset shader effect to the default rendering mode in console GUI mode.
default_shader
set_shaderLoad and apply a custom shader file in console GUI mode.
set_shader "path/to/shader.glsl"
clearClear the current console output buffer.
clear
helpShow built-in help for shell commands.
help
aboutDisplay runtime information about the shell build and environment.
about
wsl_on / wsl_offEnable or disable WSL command routing on supported Windows builds.
wsl_on
wsl_off
argvAccess command-line arguments passed to the current script or invocation context.
argv indexargv "length"argv "all"
exitTerminate the shell immediately.
exit
echoPrints its arguments to standard output, expanding any variables.
echo [ARG]...
VAR).echo Hello USER
catConcatenates and displays file contents, or reads from standard input if no files are specified.
cat [FILE]...
grepSearches input or files for lines matching a pattern, optionally using regular expressions.
grep [--r|--e] PATTERN [FILE]...
--r or --e: enable extended regex matching.printPrint arguments line-by-line. Supports optional numeric formatting modes for integer/float output.
print [--i|--f] ARG...
cdChange the shell’s current working directory.
cd DIR
list (ls)List the contents of a directory.
ls [DIR]
sortSorts lines of text from files or standard input.
sort [FILE]...
findRecursively search a directory tree for filenames containing a given pattern.
find PATH PATTERN
pwdPrint the current working directory.
pwd
mkdirCreate new directories.
mkdir [--p] DIR...
--p: create parent directories as needed.cpCopy files or directories.
cp [--r] SOURCE... DEST
mvRename or move files and directories.
mv SOURCE... DEST
touchUpdate file timestamps or create files if they do not exist.
touch FILE...
headDisplay the first part of files or input.
head [--n N] [FILE]...
tailDisplay the last part of files or input.
tail [--n N] [FILE]...
wcCount lines, words, and characters in files or input.
wc [--l] [--w] [--c] [FILE]...
sedPerform basic stream editing via substitution expressions.
sed [options] 's/pattern/replacement/[g]' [FILE]
-n: suppress automatic printing.-i: edit files in place.printfFormatted printing, similar to C's printf.
printf FORMAT [ARG]...
testEvaluate conditional expressions for use with if, while, and boolean branching. Returns 0 for true and non-zero for false.
test ARG...
if test count --gt 10
then
echo "large dataset"
fi
cmdExecute an MXCMD script file within the current shell runtime. Useful for modular scripts and task automation.
cmd SCRIPT_FILE
cmd "./scripts/deploy.mxcmd"
visualRender a script's abstract syntax tree (AST) into an HTML visualization for debugging parser/structure issues.
visual SCRIPT_FILE OUTPUT_HTML
visual "build.mxcmd" "build_ast.html"
atExtract an element by index from a newline-separated list.
at LIST INDEX
lenCount items in a list, either by lines or words.
len LIST
indexExtract a substring by start position and length.
index STRING START LENGTH
strlenGet the length of a string.
strlen STRING
strfindFind the position of a substring within a string.
strfind START STRING SEARCH
strfindrFind the position of a substring within a string, searching from the right (end of string).
strfindr STRING SEARCH
strtokSplit a string into tokens using a delimiter and return the result as a newline-separated list.
strtok STRING DELIMITER
externRegister an external function from a shared library as a command.
extern LIBRARY FUNCTION COMMAND_NAME
libmath.so with a function add_numbers:
extern "math" "add_numbers" "add"
Named list helpers for dynamic collections, temporary buffers, token streams, and script-level data manipulation.
list_new NAME — Create a new listlist_add NAME VALUE — Add a value to a listlist_remove NAME INDEX — Remove an item at specified indexlist_get NAME INDEX — Get an item at specified indexlist_set NAME INDEX VALUE — Set an item at specified indexlist_clear NAME — Clear a specific listlist_clearall — Clear all listslist_exists NAME — Check if a list existslist_init NAME VALUE SIZE — Initialize a list with a value repeated SIZE timeslist_len NAME — Get the length of a listlist_tokens NAME — Display all values in a list, one per linelist_sort NAME — Sort a list in ascending orderlist_reverse NAME — Reverse the order of elements in a listlist_shuffle NAME — Randomly shuffle the elements of a listlist_copy SOURCE DEST — Copy a list to a new listlist_pop NAME — Remove and return the last element of a listlist_concat LIST1 LIST2 — Concatenate the second list to the firstrandGenerate a pseudo-random number between MIN and MAX (inclusive), useful for randomized logic and procedural scripts.
rand MIN MAX
rand 1 100 # Generates a random number between 1 and 100
exprEvaluate expressions and return computed values. Supports arithmetic, comparison, and logical operators.
expr EXPRESSION
expr "5 + 3 * 2" # Returns 11
expr "10 > 5 && 3 < 4" # Returns 1 (true)
commandsList all available commands in the shell, including built-in, user-defined, and externally loaded commands.
commands
debug_set <VAR> <VAL> — Set a debug variable.debug_get <VAR> — Get a debug variable.debug_list — List debug variables.debug_clear <VAR> — Clear a debug variable.debug_clearall — Clear all debug variables.debug_search [PATTERN] — Search debug variables.dump FILENAME — Dump variable table to a file.getlineRead one full line from standard input and assign it to a variable.
getline variable
printf "enter input: " && getline value
regex_matchCheck whether the entire string matches a regular expression pattern.
regex_match PATTERN STRING
if test $(regex_match "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" email) --eq "1"
then
echo "Valid email format"
fi
regex_replaceReplace every region matching a regular expression pattern with a replacement string.
regex_replace PATTERN REPLACEMENT STRING
sanitized = $(regex_replace "[^a-zA-Z0-9]" "_" string)
regex_searchSearch a string for at least one match to the given regular expression pattern.
regex_search PATTERN STRING
if test $(regex_search "[0-9]{3}-[0-9]{3}-[0-9]{4}" text) --eq "1"
then
echo "Found a phone number"
fi
regex_splitSplit a string using a regular-expression delimiter and return a newline-separated token list.
regex_split PATTERN STRING
parts = $(regex_split "," "a,b,c" )
tokenizeRun the MXCMD scanner/lexer and print the token stream for a source file. Useful for parser debugging and syntax troubleshooting.
tokenize "filename.mxcmd"
tokens = $(tokenize "build.mxcmd")