Core Commands
JSH includes a small set of built-in shell-style commands for navigating directories, reading files, printing text, creating and removing paths, and waiting for a period of time.
Overview
Most commands are implemented as JavaScript files under /sbin and are resolved through the JSH command path.
The cd command is different: it is an internal shell command because it must change the current shell working directory.
Notes
- These commands operate inside the JSH virtual filesystem, not directly on the host OS filesystem.
- Relative paths are resolved from the current JSH working directory.
cdaffects the active shell session, while commands such aspwd,ls, andrmrun as normal commands.- Some commands intentionally provide a smaller feature set than their Unix counterparts.
cat
Concatenates files to standard output. It also supports line formatting options and optional syntax highlighting for selected file types.
Syntax
cat [OPTION]... [FILE]...Options
-n, --numbernumber all output lines-E, --showEndsdisplay$at the end of each line-T, --showTabsdisplay tab characters as^I-s, --squeezesuppress repeated empty lines-c, --colorenable syntax highlighting-h, --helpshow help
With -c, syntax highlighting is supported for these extensions:
.js.json.ndjson.sql.csv.yaml.yml.toml
Usage example
/work > cat -n notes.txt
/work > cat -c script.js
/work > cat -sE log.txtcd
Changes the current working directory of the active JSH shell session.
Unlike most other commands, cd is an internal command and is not implemented as a separate /sbin/*.js file.
Syntax
cd <directory>If the target directory does not exist, cd prints an error and returns a non-zero status.
Usage example
/work > cd subdir
/work/subdir >echo
Prints its arguments separated by spaces and terminates with a newline.
Syntax
echo [ARG]...echo does not currently implement shell-style flags such as -n or escape interpretation.
It simply prints the arguments exactly as they are passed.
Usage example
/work > echo hello world
hello worldls
Lists directory contents. By default it prints entries in columns with colorized names.
Syntax
ls [OPTION]... [PATH]...Options
-l, --longuse a detailed listing view-a, --allinclude hidden entries-t, --timesort by modification time, newest first-R, --recursivelist subdirectories recursively
If no path is given, ls uses the current working directory.
It also accepts simple wildcard patterns such as * and ? in path arguments.
Usage example
/work > ls
/work > ls -la
/work > ls -t /lib
/work > ls -R src
/work > ls *.jsmkdir
Creates one or more directories.
Syntax
mkdir [OPTION]... DIRECTORY...Options
-p, --parentscreate parent directories as needed-v, --verboseprint a message for each created directory-h, --helpshow help
Without -p, creating an existing directory reports an error.
With -p, existing directories are accepted.
Usage example
/work > mkdir data
/work > mkdir -p logs/app/2026
/work > mkdir -pv build/outputpwd
Prints the current working directory.
Syntax
pwdUsage example
/work > pwd
/workrm
Removes files or directories.
Syntax
rm [OPTION]... FILE...Options
-r, -R, --recursiveremove directories and their contents recursively-d, --dir, --directoryremove empty directories-f, --forceignore nonexistent paths and suppress missing operand errors-v, --verboseprint a message for each removed path-h, --helpshow help
Important behavior:
- Removing a directory without
-ror-dreportsIs a directory -donly removes empty directories-Ris treated the same as-r--directoryis treated the same as--dir
Usage example
/work > rm old.txt
/work > rm -rf cache
/work > rm -d empty-dir
/work > rm -fv temp.txt missing.txtsleep
Waits for the specified number of seconds before returning.
Syntax
sleep [options] <sec>Options
-h, --helpshow help
The value is interpreted as seconds.
Usage example
/work > sleep 5