Here is a puzzle for bash lovers. This is taken from shell scripting community at Orkut.
Question: How to reset last element of an array even if it’s a discontinuous array.
Answer:
If you are not familiar with bash, you might find it difficult to understand. You can go through “man bash” for more details. See the details about : command and _ parameter from man page.
You can find these details under SHELL BUILTIN COMMANDS.
: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.
You can find these details under Special Parameters.
_ At shell startup, set to the absolute pathname used to invoke the shell or shell script being executed as passed in the environment or argument list. Subsequently, expands to the last argument to the previous command, after expansion. Also set to the full pathname used to invoke each command executed and placed in the environment exported to that command. When checking mail, this parameter holds the name of the mail file currently being checked.
~mohammed