So I need to match a string in given word list. For example, if I give the input like
$ sh match_the_pattern.sh -i aei words.txt
It should match the character "a" "e" and "i" in order.
the alphabets in the string must occur in the word in that order, but that other characters may occur in between.
Note : the character string may change and the dictionary may change.
My Approach :
- Read the input
- Scan for the filename
- SED or GREP combination to match the character string
What I do not know? the 3rd part.
while [[ $# -gt 0 ]]; do case $1 in -i) arg=$2 egrep "*[$argument]*" $name shift ;; esac shift done
What did not work
a+.*e+.*i+.* sh match_the_pattern.sh -i aeiou words.txt adventitious adventitiousness sacrilegious abstemious sacrilegiousness
if you notice, a,e,i,o,u are in order one after another. That is what I want. the character string which we are going to match may change.