Question: I have a file "ingredients.txt" that has a list of 38 words (one per each line). 
I have figured out how to read it into an array

```
getArray() {
    array=() 
    while IFS= read -r line 
    do
        array+=("$line")
    done < "$1"
}

getArray "ingredients.txt"

```

But now how to get output of all combinations of exactly 4 words from the list of 38?

EDIT: To respond to a comment, I do mean combinations and not permutations, and repetitions are not valid. Four unique words in each combination.

To further clarify, think of it as drawing four marbles of 38 different colors from a bag. No two colors alike. Once you draw a red one, it is impossible to draw another red one for that combination. You draw four, write down the colors, and put them back in the bag, and draw another four. If you get {blue, yellow, purple, red} and {yellow, purple, red, blue} they are not counted separately. I just want combinations, not permutations.

Also, I want each combination printed (going back to the ingredients list):
onion, cheese, meat, bun 
lettuce, carrot, celery, radish
carrot, lettuce, celery, vinegar
etc.

I hope this is clear.

Answer: 
I tried by using python

```
>>> a
['praveen', 'ajay', 'abhi', 'chetan', 'abh', 'cat']

for i in range(0,len(a),4):
...     print a[i:i+4]
...
['praveen', 'ajay', 'abhi', 'chetan']
['abh', 'cat']

```
Well, try with below code

```
getArray() {
    array=() 
    while IFS= read -r line 
    do
        array+=("$line")
    done < "$1"
    for i in ${!array[@]}
    do
           if [ ${#array[$i]} == 4 ]; then
                    echo "${array[$i]}"
           fi
    done
}

getArray "ingredients.txt"

```