Spell Check for Properties file
On unix-like systems, you can use a combination of tools on the command line. One example would be to use egrep to filter out lines starting with comment characters, cut to split the properties file on the equals sign and output the second field (right-hand side), and a pipe to a spell checker like spell.
Given this input file named resources.properties:
# Application resources
com.hello.world = Hello world.
com.module.home = hoem.
com.module.fruits = apple, bananananana, cranberry, grape, orange, strawburry
Here's an example of a command to spell check "resources.properties", and its output:
[user@host ~]$ egrep -v '^#' resources.properties | cut -d= -f2 | spell
bananananana
hoem
strawburry
The egrep -v '^#'
command filters out comments (lines that start with the pound sign). The -d=
argument to the cut
utility sets the field delimiter to the equals sign, and -f2
directs the command to output the second field -- the right-hand side of the equals sign, a.k.a. the property value / string to spell-check.
On many systems, the "spell" command is provided by the aspell utility. An alternate command line that invokes aspell directly, and offers suggestions for spelling correction:
egrep -v '^#' resources.properties | cut -d= -f2 | aspell pipe
How to run spell check on multiple files and display any incorrect words in shell script?
You can install aspell with Homebrew on OS X. brew info aspell
lists supported languages.
brew install aspell --lang=en,fi,jp
aspell check
opens a file in an interactive spell checker:
for f in *.txt; do aspell check $f; done
aspell list
prints all unrecognized words:
cat *.txt | aspell list | sort -u
Learned words are stored in .aspell.en.pws
by default. You can also exclude words in ~/Library/Spelling/en
after adding personal_ws-1.1 en
as the first line.
aspell list --personal=$HOME/Library/Spelling/en
Bash - omit lines starting with a mis-spelled word (using hunspell)
The easiest way would be to use the join
command:
$ join words.txt ok_words.txt
bird 10
cat 12
dog 42
fish 2
or to preserve tabs:
$ join -t $'\t' words.txt ok_words.txt
bird 10
cat 12
dog 42
fish 2
Passing arguments to an interactive program non-interactively
For more complex tasks there is expect
( http://en.wikipedia.org/wiki/Expect ).
It basically simulates a user, you can code a script how to react to specific program outputs and related stuff.
This also works in cases like ssh
that prohibits piping passwords to it.
Related Topics
What Does Version Info in Ldd -V Mean
Docker Oci Runtime Create Failed: Container_Linux.Go:349: Starting Container Process Caused
Accessing Files Outside the Document Root with Apache
Find Command to Find Files and Concatenate Them
Can Any One Say How to Install the Slack in Ubuntu14.04 and While Trying This Was the Error
Sync Two Computers Going Through a Bridge with Rsync
Subprocess Library Won't Execute Compgen
How to Transfer Data via Dma from Ram to Ram
Collecting the Data for a Partiulcar Process from Pmu for Every 1 Milli Second
How to Read Config Files with Section in Bash Shell
How to Check If a File Contains Only Zeros in a Linux Shell
Dlopen Failed: Cannot Open Shared Object File: No Such File or Directory
Xclip Does Not Terminate When Tracing It
Changing Color of Eclipse Links in Quick Fix or Eclipse Links in Preferences on Linux
.Bashrc Syntax Error: Unexpected End of File
Extract Text Between Two Strings Repeatedly Using Sed or Awk