For permuting I prefer the python way (use tabs for the indents):
Code:
#!/usr/bin/python
from sys import *
from itertools import *
input = argv[1]
for sequence in permutations(input):
for char in sequence:
stdout.write(char)
print
An example of running the script (permute.py) after making it executable (chmod +x permute.py):
Code:
$ ./permute.py abc
abc
acb
bac
bca
cab
cba