I have a script with output for example a c d txt iso e z
I need to sort it alphabetically. These are file extensions so I cant compile it together in one word and then split up.
Can anyone help me?
Asked
Active
Viewed 1,529 times
0

Johnczek
- 532
- 9
- 30
-
Is the output all in the same line, splited by spaces? Please consider pasting your script for better reference. – Svperstar Apr 11 '16 at 11:48
1 Answers
3
If your the name of your script is foo
and it writes to stdout a string such as a c d txt iso e z, you can get the sorted list by, for instance:
sorted_output=$(foo|xargs -n 1|sort)
Of course, depending on what you are going to do with the result, it might make more sense to store it into an array.

user1934428
- 19,864
- 7
- 42
- 87