I do not believe this is true permutations, as I do not want a combination of IDs duplicated in a different order.I have a lists of 1 to x IDs:List #1:  1001 1002 1003 1004List #2:  1002 1004 1005List #3:  1001 1003 1006List #4:  1002 1003 1005 1006 1007 1008 1010etc.Keeping in mind the lists are variable in length, I need a way to get all possible combinations of the IDs in a list (but not the same combination in a different order).For instance, List #1 would return:10011002100310041001 10021001 10031001 10041002 10031002 10041003 10041001 1002 10031001 1002 10041001 1003 10041002 1003 10041001 1002 1003 1004List #2 would return:1002100410051002 10041002 10051004 10051002 1004 1005I need the solution to work in a bash script.  In all fairness, I could call Python, PHP, etc.Any input is greatly appreciated.
Permutations in Bash (Combinations of IDs/Tokens)
shell script;permutations
Using python:>>> from itertools import combinations>>> a = (1001, 1002, 1003, 1004)>>> [list(combinations(a, i)) for i in range(1, len(a)+1)][[(1001,), (1002,), (1003,), (1004,)], [(1001, 1002), (1001, 1003), (1001, 1004), (1002, 1003), (1002, 1004), (1003, 1004)], [(1001, 1002, 1003), (1001, 1002, 1004), (1001, 1003, 1004), (1002, 1003, 1004)], [(1001, 1002, 1003, 1004)]]To display this in  a nicer format:>>> print '\n'.join('\n'.join(' '.join(str(i) for i in c) for c in combinations(a, i)) for i in range(1, len(a)+1))10011002100310041001 10021001 10031001 10041002 10031002 10041003 10041001 1002 10031001 1002 10041001 1003 10041002 1003 10041001 1002 1003 1004Running from a bash command line$ python -c from itertools import combinations; a=(1001, 1002, 1003, 1004); print '\n'.join('\n'.join(' '.join(str(i) for i in c) for c in combinations(a, i)) for i in range(1, len(a)+1))10011002100310041001 10021001 10031001 10041002 10031002 10041003 10041001 1002 10031001 1002 10041001 1003 10041002 1003 10041001 1002 1003 1004Running as a shell functionLet's define a shell function:$ combo() { python -c import sys, itertools; a=sys.argv[1:]; print '\n'.join('\n'.join(' '.join(str(i) for i in c) for c in itertools.combinations(a, i)) for i in range(1, len(a)+1)) $@; }We can run the function as follows:$ combo 1001 1002 1003 100410011002100310041001 10021001 10031001 10041002 10031002 10041003 10041001 1002 10031001 1002 10041001 1003 10041002 1003 10041001 1002 1003 1004