1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #!/bin/bash
echo $1 | awk '
function recurs(l_mot, l_taille_mot, lt_mot, l_sortie_index, i)
{
l_taille_mot=split(l_mot, lt_mot, "")
l_sortie_index=taille_mot-l_taille_mot+1
for (i=1; i<=l_taille_mot; i++)
{
t_sortie[l_sortie_index]=lt_mot[i]
nouveau_mot=l_mot
sub(lt_mot[i], "", nouveau_mot)
if (nouveau_mot != "") {recurs(nouveau_mot)}
}
if (l_sortie_index == taille_mot)
{
for (j=1; j<=taille_mot; j++)
{
printf "%c ", t_sortie[j]
}
print ""
}
}
{
taille_mot=length($0)
recurs($0)
}' |
Partager