I would like to sort the characters in a string.
E.g.
echo cba | sort-command
abc
Is there a command that will allow me to do this or will I have to write an awk
script to iterate over the string and sort it?
I would like to sort the characters in a string.
E.g.
echo cba | sort-command
abc
Is there a command that will allow me to do this or will I have to write an awk
script to iterate over the string and sort it?
Please find the following useful methods:
Shell
Sort string based on its characters:
String separated by spaces:
Perl
Ruby
Bash
With bash you have to enumerate each character from a string, in general something like:
For sorting array, please check: How to sort an array in bash?
This is cheating (because it uses Perl), but works. :-P
Another
perl
one-liner-l
option@F
array@F
is printedThis will also work line wise for given input file