scripts

Scripts
git clone git://git.wimdupont.com/scripts.git
Log | Files | Refs | LICENSE

wta (700B)


      1 #!/bin/bash
      2 
      3 word=$1
      4 word_file="$HOME/.config/scripts/wordtester.csv"
      5 
      6 mkdir -p $HOME/.config/scripts
      7 
      8 if [ -z ${word} ]; then
      9 	echo "What word do you want to add?"
     10 	read word
     11 fi
     12 
     13 found_words=$(grep "^${word}" "${word_file}")
     14 
     15 function continue_prompt () {
     16 	read -p "Do you want to proceed? (y)es/(n)o " yn
     17 	case $yn in 
     18 		yes|y ) echo proceeding;;
     19 		no|n ) 	echo exiting;
     20 			exit;;
     21 		* ) 	echo -e "invalid response\nexiting" >&2;
     22 			exit 1;;
     23 	esac
     24 }
     25 
     26 if [ -z "${found_words}" ]; then
     27 	echo Word not found
     28 else
     29 	printf " - Found:\n${found_words}\n\n"
     30 	continue_prompt
     31 fi
     32 
     33 dict "${word}"
     34 
     35 continue_prompt
     36 
     37 echo "${word}" >> "${word_file}"
     38 
     39 sort -o "${word_file}" "${word_file}"
     40 
     41 echo "${word} added."