0
vim command.txt
key="123456"
openssl enc -des3 -a -salt -in /tmp/test   -k ${key} -out /tmp/test.asc

In vim's command mode :1,2!bash,the file /tmp/test was encrypted into /tmp/test.asc ,but all the lines in command.txt dispear,where is my lines in the edited file command.txt?

Why all lines dispear after executing the lines on edited file?

How to recover it?
How to keep all the lines in vim after executed by bash?

showkey
  • 1,130
  • 2
  • 11
  • 30
  • Im afraid your question is rather unclear. Can you be more explicit about the steps you take that result in this behavior? – D. Ben Knoble Mar 28 '18 at 15:05
  • 1
    Answer from @Rich is correct explanation. If you want to restore your lines, simply press u afterward. – tivn Mar 29 '18 at 10:24
  • 2
    @tivn Alternatively, use an approach that doesn't make them disappear to begin with, like :[range]w !bash :) – ZeroKnight Apr 02 '18 at 05:39

2 Answers2

2

Vim is removing the lines because you are instructing it to do so.

The feature you're invoking with your command is the "filter" feature. This takes all or some of the contents of a file, passes them to an external command on standard input, and then replaces them with the output of that command.

You are passing two commands to the bash program. It executes them, but doing so does not result in any output, so the net effect on your file is that the lines are removed.

See :help filter for more details, and specifically :help :range! for the variation you're using.

I would offer some more suggestions on better methods to achieve your goal, but I'm afraid I don't really understand what it is you're trying to do.

Rich
  • 31,891
  • 3
  • 72
  • 139
1
:1,2 !bash

the line in edited file lost after executing bash command

:1,2 w  !bash

the line in edited file remained after executing bash command

showkey
  • 1,130
  • 2
  • 11
  • 30