Skip to main content

Overview

The help command displays a complete reference of all Nash commands, their options, and shell syntax. It provides quick access to command usage information directly from the command line.

Syntax

help [COMMAND]

Description

The help command shows comprehensive documentation for Nash, including:
  • All available built-in commands with descriptions
  • Command-line options and flags
  • Shell syntax features (pipes, redirects, chaining, etc.)
  • Usage examples
Currently, the Nash help command displays all available commands and syntax in a single reference. Command-specific help may be added in future versions.

Examples

Display Help

help

View Help Output

help | head -20
# View first 20 lines of help

Search Help

help | grep jq
# Find jq-related information

Save Help to File

help > nash-reference.txt
cat nash-reference.txt

Help Content Overview

The help output includes these sections:

Available Commands

Complete list of all 28+ built-in commands:
cat    [-n] [file...]       Print file(s) or stdin
cp     SRC DST              Copy file
mv     SRC DST              Move or rename file
rm     [-r] [-rf] PATH...   Remove file or directory
touch  FILE...              Create empty file

Syntax Reference

Shell features and syntax:
# Simple command
cmd arg

# Pipe stdout to stdin
cmd | cmd

# Redirect stdout (overwrite)
cmd > file

# Redirect stdout (append)
cmd >> file

# Read stdin from file
cmd < file

# Run second if first succeeds
cmd && cmd

# Run second if first fails
cmd || cmd

# Run both unconditionally
cmd ; cmd

# Subshell (isolated environment)
( cmd )

# Variable expansion
$VAR  ${VAR}

# Command substitution
$(cmd)

# Quoting
'text'  "text"

# Comments
# comment

Test Operators

File, string, and numeric test operators:
test EXPR / [ EXPR ]      Evaluate expression
  -f FILE   true if regular file
  -d FILE   true if directory
  -e FILE   true if exists
  -z STR    true if empty string
  -n STR    true if non-empty string
  = != -eq -ne -lt -le -gt -ge

Practical Use Cases

Quick Reference

# Forgot a command's options
help | grep grep
# Output:
#   grep   [-v] [-i] [-n] PATTERN [file...]  Filter lines

Learn Available Commands

# See what commands are available
help | grep -A 30 "AVAILABLE COMMANDS"

Syntax Lookup

# How do I do pipes again?
help | grep pipe
# Output:
#   cmd | cmd            Pipe stdout to stdin

Find Command by Function

# What command searches for files?
help | grep -i search
# Output:
#   find   [path] [options]     Search for files

Export Reference

# Save help for offline reference
help > ~/nash-help.txt

# View later
cat ~/nash-help.txt | grep test

Script Documentation

# Add help reference at top of script
echo "#!/usr/bin/env nash" > script.sh
echo "# Run 'help' for command reference" >> script.sh
echo "" >> script.sh
echo "ls -la" >> script.sh

Using Help with Other Commands

help | grep "jq"

Paging Long Output

The help output is quite long. While Nash doesn’t have a built-in pager like less, you can use:
# View first 20 lines
help | head -20

# View specific section
help | grep -A 10 "SYNTAX"

# Save and view
help > help.txt
cat help.txt

Help vs. Documentation

Quick reference built into Nash:
help
# Shows all commands and syntax

Finding Specific Information

# Find all flag options
help | grep "\[-"

# Find redirect operators
help | grep -E "(>|<|>>)"

# Find test operators
help | grep "test" -A 7

# Find chaining syntax
help | grep -E "(&&|\|\|)"

Common Patterns

Quick Command Lookup

# Forgot grep options
help | grep "grep"
# Output:   grep   [-v] [-i] [-n] PATTERN [file...]  Filter lines

Verify Command Exists

# Does Nash have a sort command?
help | grep -q "sort" && echo "Yes" || echo "No"
# Output: Yes

List All Commands

# Extract command names only
help | grep "^  [a-z]" | cut -d' ' -f3 | sort

Exit Status

The help command always returns exit code 0 (success).

Notes

  • Help is displayed on stdout, not stderr
  • Help output can be piped and redirected
  • The help text is comprehensive but concise
  • Future versions may support command-specific help: help COMMAND
  • Help shows syntax, not detailed examples (see online docs for examples)
  • which - Check if specific commands exist
  • history - View previously executed commands

Build docs developers (and LLMs) love