Shell script sort a string

374 views Asked by At

i have a shell script variable etc "string" i want to give this string as value of another variable,abc sorted like string=CDA want to add ADC to a "ordered" variable

$string=CDA
$ordered=ADC
1

There are 1 answers

0
anubhava On BEST ANSWER

You can do:

> string=CDA
> s=$(grep -o . <<<"$string"|sort|tr -d "\n")
> echo "$s"
ACD