In shell scripting, $# expands to the number of positional parameters passed to the script. Meanwhile, $? holds the exit status of the last executed command, $! contains the process ID of the most recent background command, and $$ represents the current shell's process ID.