Sarath S Sarath S - 1 year ago 93
Bash Question

What will this command do

I accidentally ran the following command in my console.It was a copy paste error.

vim -> /etc/apache2/sites-available/25-xyz-https.conf.


But after that my 25-xyz-https.conf got corrupted. Eventhough I recovered the file just curious to understand what has happened.

Answer Source

This happens:

vim -

means open stdin in vim.

> file

is an output redirection by the shell. Stdout of the (vim) process will get stored in file. file will get truncated by the shell before the (vim) process get's started.


I recommend to always put a # into the shell before pasting things into the shell. That gives you a chance to review the line before executing it, especially if you paste the line together with the line break at the end. (which would execute it right away)

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