Shell Script To Reverse Command Line Input / Numbers

Posted on in Categories Academic last updated October 20, 2008

8 comment

  1. Is there a way to get the result to print out on separate lines? e.g.

    Numbers are: 1 2 3 4
    Reverse Order:
    1
    2
    3
    4

  2. I am getting wrong results.. Is there anything wrong???

    1. Hey, CLA`s cannot be passed to the script using commas,
      sh reverse.sh 3 4 9 12

      Use space instead of comma. :)

      Cheers,
      Arun D Patil

  3. if [ $# -lt 1 ]; then echo “Usage: $(basename $0) arg1 arg2 … argN “; exit 1; fi

    echo “Numbers are: $@”
    for n in $@; do x=”$n $x”; done
    echo “Reverse order: $x”

Leave a Comment