When I execute the command cd / | vi, it goes to the vi editor. When I type any command it does not display the command but it gets executed and the command that is executed is not shown in the history.

  • try cd /&& vi /path/to/file – eyoung100 Sep 15 '14 at 14:28
  • stty sane is working ,but in command history ,command what i have typed is not shown. – KALAI SELVAN Sep 15 '14 at 14:39
  • 1
    Answer to the question "what is happening" is that the output of the "cd /" command (which doesn't output anything) is piped to the input of vi, which doesn't like that as it expects input from the user on its standard input. So just don't do that. – wurtel Sep 15 '14 at 14:46
  • What shell (bash, zsh, etc) are you typing this command in to? What terminal emulator (xterm, rxvt, urxvt, etc)0 are you using, if any? – Bruce Ediger Sep 15 '14 at 14:47

The "|" is a pipe command. Some programs take their input from a pipe, such as "less" or "more".

If you run the following command:

$ ls -l | less

The output of "ls" will be piped through the pager, "less".

If you want to run one command then the other from the same line without the pipe you would either use ";" or "&&" (which is probably what you're looking for) instead of the pipe "|" command.

More direct to your question, what happens is your command is trying to output the content of "cd" to vi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.