Output arguments in sorted order

Viewed 6288

I need to write a bash script that prints out its command line arguments in sorted order, one per line.

I wrote this script and it works fine, but is there any other way? Especially without outputting it to a file and sorting.

#!/bin/bash

for var in $*
do
    echo $var >> file
done

sort file
rm file

Test run of the program:

$ script hello  goodbye zzz aa
aa
goodbye
hello
zzz
2 Answers
Related