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

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.

#!/bin/bash
# Write a shell script wrapper to check the spellings of any text document given as an argument.
# -------------------------------------------------------------------------
# Copyright (c) 2008 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
file="$1"
# Path to ispell / spell command
SPELL="/usr/bin/ispell"
 
# make sure argument is given to script
if [ $# -eq 0 ]
then
	echo "Syntax: $(basename $0) file"
	exit 1
fi
 
if [ ! -f $file ]
then
	echo "Error - $file not a file!"
	exit 2
fi
 
# make sure ispell is installed
if [ ! -x $SPELL ]
then
	echo "Error - $SPELL binary file does NOT exists; cannot check the spellings of $file."
	exit 3
fi
 
# now check the spellings
$SPELL $file
Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics:
CategoryList of Unix and Linux commands
File Management cat
Firewall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilities dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searching grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.