So, I want to pass 2 arguments and want those arguments to be processed in combination and separately too. I have coded the switch case to process them separately but I am not sure how to do process them together.
$ sh match_the_pattern.sh -a 6 -b 5 words.txt
Here,
- -a: at least number of letters specified.
- -b: at most number of letters specified.
What I am looking for?
when I get -a and -b together, first the script should list all the words which have at least given number of words, save, then out of those, it should process with the -b, that is the most number of letters in the result we got from the -a, then print the count.
This is a double filter, it is not like you posted both of them individually.
while [[ $# -gt 0 ]]; do
    case $1 in
    -a)
        argument=$
        egrep "^[[:alnum:]]{$argument,}$" $dictionyname | wc -l
        shift ;;
    -b) 
        arg=$2
        egrep "^[[:alnum:]]{0,$argument}$" $dictionyname | wc -l
        shift ;;
    esac
    shift
done
$ sh match_the_pattern.sh -a 6 -b 5 words.txt
7000
$ sh match_the_pattern.sh -a 6 words.txt
115690
$ sh match_the_pattern.sh -b 5 words.txt
12083
Note, I do know how to process -a and -b, I do not know how to combine the results of -a and -b when passed together in the argument...
If right now, I pass the command, I am getting this output :
$ sh match_the_pattern.sh -a 6 -b 5 words.txt
115690
12083
So it is processing a and b but giving the results one after another.
 
    