String sorting algorithm in shell script.
I have done it for numbers,but not able to do for string.
EX:- I am kohali. It should be like am i kohali
Below script will help you
str='I am kohali'
for i in `echo $str`; do
echo $i
done | sort
Below one will accept input from user
read -p "Enter your string:" str
for i in `echo $str`; do
echo "$i"
done | sort
Output
am I kohali
echo "i am kohal" | tr ' ' '\n' | sort | tr '\n' ' 'cat $filename; do echo $i done | sort | tr '\n' ' '