|
| Total Answers and Comments: 4 |
Last Update: November 07, 2008 Asked by: Nehashri |
|
| | |
|
Submitted by: UncaAlby str="alpha beta gamma" echo $str | awk '{ for (i=NF; i>0; i--) printf ("%s ",$i); printf("n"); }'
Results:
gamma beta alpha
If you're talking about parameters passed into a Shell script, that can be modified to the following:
echo $* | awk '{ for (i=NF; i>0; i--) printf ("%s ",$i); printf("n"); }'
The previous answer using "awk" reversed all the characters, resulting in:
ammag ateb ahpla
Which I don't think is what was meant in the phrase, positional parameters.
Although, if reversing all the characters is what you wanted, then that's one good way to do it.
Above answer was rated as good by the following members: jrgalaura | Go To Top
|