15

Is there a way to hide what I'm typing in a shell, so the terminal doesn't echo my keystrokes, while still keeping the output of the command?

For example, if I run ip addr show, the only thing on the screen should be the output from that command -- not the "ip addr show" that I typed.

Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233
Mughil
  • 1,973
  • 1
    Hi. Can you be bit more specific about, content? – Nikhil Mulley Jan 08 '12 at 16:01
  • 1
    Do you mean hiding the standard input like when typing the password on login? Are you using bash? Provide some more information please. –  Jan 08 '12 at 16:08
  • content means commands, for example if i type an command "ip addr show" it must be not visible in the bash terminal what i am typing . But it can i view the output of it – Mughil Jan 08 '12 at 16:41
  • 3
    That's a weird requirement. What are you trying to achieve? Note that with typical shells, the command will also be entered in the history and saved to disk. – Gilles 'SO- stop being evil' Jan 08 '12 at 17:04

1 Answers1

29

If you want to disable echo of the commands you type, try this:

stty -echo

You can re-enable echo using this command:

stty echo

Note that the output of commands will show up in a somewhat different way, see this example session:

$ pwd
/tmp
$ stty -echo
$ /tmp

This resulted from typing pwd, return, stty -echo, return, pwd, return.

Adam Zalcman
  • 4,331
  • 3
    Note that this may or may not work depending on your shell, and perhaps on what oddities you put in your prompt. Also the setting applies to everything in that terminal; if you run a full-screen command it's likely to reset to stty +echo. – Gilles 'SO- stop being evil' Jan 08 '12 at 17:04