I need to create a script, that will read a word as an input and provide the output as shuffled letters of the word.
Eg: Input word as "Azharudeen" and output should be as "zAhauredne"
You could do this with a short Python script specified on the command line:
$ python -c "import random,sys; chars=list(sys.argv); random.shuffle(chars); print(''.join(chars))" Azharudeen neuAazrhed
Not the most elegant, but this works:
$ echo `echo "Azharudee" | sed -e 's/./&\n/g' | shuf` | sed -e 's/ //g' Auerdzhae
Edit (for explanation):
puts that word into standard output, which is piped into
sed -e 's/./&\n/g'
which places each character onto its own line, by replacing each character by itself followed by a newline character, and pipes it into
which randomly shuffles the lines it is given and puts them on standard output.
Meanwhile this outer layer wraps all the above (as "...") in
echo `...` | sed -e 's/ //g'
The "echo" causes the multiple lines produced by the first set of commands to be combined into a single line, and the "sed" replaces all the spaces with nothing.
Note that it might have been visually better had I used
$(echo ... shuf) rather than enclosing it in grave accents, which have the same effect but are harder to see.