If the list of positional parameters is:
$ set -- 0wer 1wdfg 2erty 333 4ffff 5s5s5 Then this will print the arguments without the last:
$ echo "${@:1:$#-1}" 0wer 1wdfg 2erty 333 4ffff Of course, the parameters could be set to that as well:
$ set -- "${@:1:$#-1}" $ echo $@ 0wer 1wdfg 2erty 333 4ffff That works in bash version 2.0 or above.
For other simpler shells, you need a (somewhat tricky) loop to remove the last parameter:
unset b; for a; do set -- "$@" "$b";${b+"$b"}; shift; b="$a"; done