Skip to content

Commit

Permalink
add basic word addition functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
fin-w committed Feb 6, 2023
1 parent b412a45 commit 50ee063
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions add
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# add a word to the dictionary

# usage:
# ~ $ add -w "enghraifft"
# ~ $ add ffeil.txt
#
# ~ $ ls ffeil.txt
# amlddiwylliannedd
# enghraifft
# ~ $
#

if [[ $1 -eq "-w" ]] ; then
if grep -Fxq $2 ./dictionaries/word_list.txt ; then
echo "$2 is already in word list"
else
echo $2 >> dictionaries/word_list.txt
sort -u dictionaries/word_list.txt > dictionaries/dict.tmp
wc -l < dictionaries/dict.tmp > dictionaries/mwy.dic
cat dictionaries/dict.tmp >> dictionaries/mwy.dic
rm dictionaries/dict.tmp
fi
else
if [[ -f $1 ]] ; then
cat $1 >> dictionaries/word_list.txt
sort -u dictionaries/word_list.txt > dictionaries/dict.tmp
wc -l < dictionaries/dict.tmp > dictionaries/mwy.dic
cat dictionaries/dict.tmp >> dictionaries/mwy.dic
rm dictionaries/dict.tmp
fi
fi

0 comments on commit 50ee063

Please sign in to comment.