aspell

text processinglinux
The aspell command is one of the most frequently used commands in Linux/Unix-like operating systems. aspell The aspell command is a spell checker that can be used interactively or in batch mode to check the spelling of text files. It offers suggestions for misspelled words and can be customized with different dictionaries and personal word lists.

Quick Reference

Command Name:

aspell

Category:

text processing

Platform:

linux

Basic Usage:

aspell [options] [arguments]

Common Use Cases

  • 1

    Text spell checking

    Check spelling in text files and documents

  • 2

    Document validation

    Validate spelling in documentation and reports

  • 3

    Content quality assurance

    Ensure content quality by checking for spelling errors

  • 4

    Automated proofreading

    Automate spell checking in content management systems

Syntax

aspell [options] <command>

Options

Option Description
-c, --check Spell check a single file
-a, --pipe Run in pipe mode (ispell compatible)
-l, --list List misspelled words from standard input
--mode=MODE Set input filter mode (tex, html, sgml, email, url, etc.)
--lang=LANG Use the given language dictionary (e.g., en, fr, de)
-d, --master=DICT Use the given dictionary
-p, --personal=FILE Use a personal dictionary file
--ignore=NUM Ignore words with less than NUM characters
--sug-mode=MODE Set suggestion mode (ultra, fast, normal, slow, bad-spellers)
--encoding=ENC Set the character encoding (utf-8, iso8859-1, etc.)
--dont-backup Don't create a backup file when checking
--dont-suggest Don't suggest replacement words
--suggest Suggest replacement words
--word-list-path=PATH Set the path where personal word lists are stored
--add-filter=FILTER Add a filter to the filter chain
--rem-filter=FILTER Remove a filter from the filter chain
--per-conf=FILE Set personal configuration file
--conf=DIR Set main configuration directory
--conf-dir=DIR Set main configuration directory
--data-dir=DIR Set data directory
--local-data-dir=DIR Set location of local language data files
--dict-dir=DIR Set alternate dictionary directory
--help Display help message and exit
--version Display version information and exit

Examples

How to Use These Examples

The examples below show common ways to use the aspell command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

Check spelling of a file interactively
aspell check document.txt
Check a file with a specific language dictionary
aspell --lang=es check spanish_document.txt
Create a personal word list
aspell --personal=./my-words.pws check document.txt
List available dictionaries
aspell dump dicts
Pipe text through aspell to check spelling
cat document.txt | aspell list
Check a file and output misspelled words
aspell list < document.txt

Advanced Examples:

Check spelling in a LaTeX file
aspell --mode=tex check thesis.tex
Check spelling in an HTML file
aspell --mode=html check webpage.html
Check with multiple personal dictionaries
aspell --personal=./technical-terms.pws --personal=./names.pws check document.txt
Use a specific encoding
aspell --encoding=utf-8 check document.txt
Create a list of misspelled words with line numbers
aspell --list --add-missing-from=document.txt < document.txt | sort -u
Check a file without modifying it, saving corrections to a separate file
aspell -c document.txt --dont-backup
Spell check with a specific suggestion mode
aspell --sug-mode=fast check document.txt
Check spelling in a programming file (skip code, check comments and strings)
aspell --mode=ccpp check program.cpp
Run a spell check in batch mode, saving results to a file
aspell list < document.txt > spelling_errors.txt
# Add a word to the personal dictionary during a check session
(type '&' at the prompt to add a word permanently)
aspell check document.txt

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Command Overview:

GNU Aspell is a free and open-source spell checker designed to replace Ispell. It provides both interactive and batch spell-checking capabilities, with support for multiple languages and document formats. Aspell is known for offering better suggestions for misspelled words than many other spell checkers.

Operating Modes:

  • Interactive mode (check command): Opens a UI where you can check and correct each misspelled word
  • List mode (list command): Outputs a list of misspelled words
  • Pipe mode (pipe command): Behaves like Ispell's pipe mode for compatibility with other programs
  • Config dump (dump command): Outputs various configuration information

Supported Document Types:

Aspell can handle various document formats through its mode option:

  • none: Plain text with no special processing
  • url: Text with URLs and email addresses
  • email: Email messages
  • sgml: SGML/XML documents
  • html: HTML documents
  • tex: TeX/LaTeX documents
  • texinfo: Texinfo documents
  • nroff: Nroff/Troff/Groff documents
  • man: Man pages
  • ccpp: C/C++ source code (spellchecks comments and strings)
  • perl: Perl source code
  • python: Python source code

Interactive Commands:

When using interactive mode (aspell check), you can use these commands:

  • Space: Accept the word this time
  • r: Replace with the suggested word or a manually entered one
  • a: Add the word to your personal dictionary
  • l: Add the word to the current session (forgotten at exit)
  • i: Ignore the word for the rest of the session
  • x: Exit the program, saving changes
  • q: Quit without saving changes
  • ?: Show help screen
  • number: Replace with the suggestion at that number

Personal Word Lists:

Aspell maintains personal word lists to remember words you've added:

  • Personal word lists typically have the .pws extension
  • By default, Aspell looks for ~/.aspell.[lang].pws
  • You can specify a custom personal word list with --personal=FILE
  • Personal word lists are plain text files that can be edited directly
  • The first line of a personal word list contains metadata (including encoding)

Replacement Modes:

Aspell offers several suggestion modes for misspelled words:

  • ultra: Ultra fast, but fewer suggestions
  • fast: Less accurate but faster
  • normal: Default balance of speed and quality
  • slow: More accurate but slower
  • bad-spellers: Most accurate but slowest, best for those with severe spelling difficulties

Dictionary Management:

Aspell supports multiple dictionaries and languages:

  • Use aspell dump dicts to see available dictionaries
  • Dictionaries are typically installed via the package manager (e.g., apt install aspell-en)
  • Aspell looks for dictionaries in /usr/lib/aspell or /usr/share/aspell
  • Dictionary files have .rws extension for the main wordlist

Configuration Files:

Aspell's behavior can be customized with configuration files:

  • System-wide config: /etc/aspell.conf
  • Personal config: ~/.aspell.conf
  • These are plain text files with option=value pairs
  • Run aspell dump config to see current configuration

Language Support:

Aspell has dictionaries for many languages:

  • Set language with --lang=LANG where LANG is a language code (en, fr, de, etc.)
  • Some languages have multiple variants (e.g., en_US, en_GB)
  • Language-specific dictionaries must be installed separately
  • Some languages may require specific encodings (set with --encoding)

Integration with Other Tools:

Aspell can be integrated with various tools:

  • Text editors: Many editors like Vim, Emacs, and Nano can use Aspell
  • Mail clients: Can be used for spell checking emails
  • Build systems: Can be part of documentation generation pipelines
  • Git hooks: Can check commit messages or documentation

Common Issues and Solutions:

  • Encoding problems: Use --encoding=utf-8 for Unicode text
  • Markup in documents: Use the appropriate mode (html, tex, etc.)
  • Technical terms: Create a domain-specific personal dictionary
  • Performance issues: Use faster suggestion modes for large documents
  • Missing dictionaries: Install the required language pack

Compared to Alternatives:

  • Ispell: Aspell is designed as a more modern replacement with better suggestions
  • Hunspell: Used by many office suites, better with compound words in some languages
  • Language-specific tools: May offer better support for specific languages
  • Grammar checkers: Tools like LanguageTool go beyond spelling to check grammar

Important Notes:

  • Aspell does not check grammar, only spelling
  • For multi-language documents, you need to check each language separately
  • Personal dictionaries are not checked for correct spelling
  • Aspell can be CPU-intensive with large documents and comprehensive dictionaries
  • For programming files, only comments and strings are checked by default
  • Aspell creates backup files by default when modifying documents

Related Commands:

  • ispell: Older spell checker that Aspell was designed to replace
  • hunspell: Alternative spell checker used in many office suites
  • spell: Simple UNIX spell checker
  • grep: Can be used with word lists to find potentially misspelled words
  • sed: Stream editor often used to process Aspell output
  • awk: Text processing tool useful for working with spell checker output
  • wc: Count words in a document
  • look: Display lines beginning with a given string (useful for dictionary lookups)
  • languagetool: Grammar, style and spell checker

Common Use Cases

Text spell checking

Check spelling in text files and documents

Document validation

Validate spelling in documentation and reports

Content quality assurance

Ensure content quality by checking for spelling errors

Automated proofreading

Automate spell checking in content management systems

Multi-language support

Check spelling in multiple languages and dialects

Related Commands

These commands are frequently used alongside aspell or serve similar purposes:

Use Cases

1

Text spell checking

Check spelling in text files and documents

2

Document validation

Validate spelling in documentation and reports

3

Content quality assurance

Ensure content quality by checking for spelling errors

4

Automated proofreading

Automate spell checking in content management systems

5

Multi-language support

Check spelling in multiple languages and dialects

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the aspell command works in different scenarios.

$ aspell
View All Commands