Shell script to check the spellings of any text document given as an argument

in Categories Academic, File-management last updated September 13, 2008

A spell checker is an applications program that flags words in a document that may not be spelled correctly. Spell checkers may be stand-alone capable of operating on a block of text, or as part of a larger application, such as a word processor, email client, electronic dictionary, or search engine.

Ispell is a spelling checker for Unix that supports most Western languages. It offers several interfaces, including a programmatic interface for use by editors such as emacs. You can use any other spell program available under your UNIX operating system such as aspell.

aspell is a free software spell checker designed to replace Ispell. It is the standard spell checker for the GNU software system. Dictionaries for it are available for about 70 languages. Set SPELL path to use aspell.

This script also demonstrate how to verify various things such as find out if file exists or not or check for passed command line arguments.

# Write a shell script wrapper to check the spellings of any text document given as an argument.
# -------------------------------------------------------------------------
# Copyright (c) 2008 nixCraft project <>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit for more information.
# -------------------------------------------------------------------------
# Path to ispell / spell command
# make sure argument is given to script
if [ $# -eq 0 ]
	echo "Syntax: $(basename $0) file"
	exit 1
if [ ! -f $file ]
	echo "Error - $file not a file!"
	exit 2
# make sure ispell is installed
if [ ! -x $SPELL ]
	echo "Error - $SPELL binary file does NOT exists; cannot check the spellings of $file."
	exit 3
# now check the spellings
$SPELL $file

Share this on: