Lee Xu Lee Xu - 1 year ago 112
Bash Question

Why does echo $-1 output this?

Can someone explain me what is happening here? What does the output means?

:$ echo $-3
:$ echo $-2
:$ echo $-1


Answer Source

$- is a variable that contains the currently active shell options.


(A hyphen.) Expands to the current option flags as specified upon invocation, by the set builtin command, or those set by the shell itself (such as the -i option).

Your command is evaluating to the value of - then a number.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download