Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
source | link

There are many effective ways to do what you want, either within vi(m) or outside vi(m).

Run your command, produce a (temporary) file, then edit the file (see Joseph R.'s answersee Joseph R.'s answer)

grep -e"Peu[gG]eot" carlist.txt && vi /tmp/peugeot.txt

Run your command (in the background) to produce a temporary file, and edit the file, using ":e!" to refresh your file as it is produced (this is useful for logfiles, and other files being produced by another process, e.g. cron?),

grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt &
vi /tmp/peugeot.txt

Run vi(m), and run a child process to create the temporary file, and then read it,

vi
:!grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt
:r /tmp/peugeot.txt

Or, just switch to the file,

:e /tmp/peugeot.txt

Run vi(m), and use the double-bang "!!" to have vi run the child command, taking the results and inserting them into the current location (overwrites the current line, so make sure you have a blank line),

vi
i
here
empty
there
<esc>
kk
!!grep -e "Peu[gG]eot" carlist.txt

And now you can write the file (if you want to) to any filename,

:w /tmp/someotherfilename.txt

And Petr Uzel's answerPetr Uzel's answer is also good,

grep -e "Peu[gG]eot" carlist.txt | vi -

Which reads from stdin

There are many effective ways to do what you want, either within vi(m) or outside vi(m).

Run your command, produce a (temporary) file, then edit the file (see Joseph R.'s answer)

grep -e"Peu[gG]eot" carlist.txt && vi /tmp/peugeot.txt

Run your command (in the background) to produce a temporary file, and edit the file, using ":e!" to refresh your file as it is produced (this is useful for logfiles, and other files being produced by another process, e.g. cron?),

grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt &
vi /tmp/peugeot.txt

Run vi(m), and run a child process to create the temporary file, and then read it,

vi
:!grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt
:r /tmp/peugeot.txt

Or, just switch to the file,

:e /tmp/peugeot.txt

Run vi(m), and use the double-bang "!!" to have vi run the child command, taking the results and inserting them into the current location (overwrites the current line, so make sure you have a blank line),

vi
i
here
empty
there
<esc>
kk
!!grep -e "Peu[gG]eot" carlist.txt

And now you can write the file (if you want to) to any filename,

:w /tmp/someotherfilename.txt

And Petr Uzel's answer is also good,

grep -e "Peu[gG]eot" carlist.txt | vi -

Which reads from stdin

There are many effective ways to do what you want, either within vi(m) or outside vi(m).

Run your command, produce a (temporary) file, then edit the file (see Joseph R.'s answer)

grep -e"Peu[gG]eot" carlist.txt && vi /tmp/peugeot.txt

Run your command (in the background) to produce a temporary file, and edit the file, using ":e!" to refresh your file as it is produced (this is useful for logfiles, and other files being produced by another process, e.g. cron?),

grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt &
vi /tmp/peugeot.txt

Run vi(m), and run a child process to create the temporary file, and then read it,

vi
:!grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt
:r /tmp/peugeot.txt

Or, just switch to the file,

:e /tmp/peugeot.txt

Run vi(m), and use the double-bang "!!" to have vi run the child command, taking the results and inserting them into the current location (overwrites the current line, so make sure you have a blank line),

vi
i
here
empty
there
<esc>
kk
!!grep -e "Peu[gG]eot" carlist.txt

And now you can write the file (if you want to) to any filename,

:w /tmp/someotherfilename.txt

And Petr Uzel's answer is also good,

grep -e "Peu[gG]eot" carlist.txt | vi -

Which reads from stdin

1
source | link

There are many effective ways to do what you want, either within vi(m) or outside vi(m).

Run your command, produce a (temporary) file, then edit the file (see Joseph R.'s answer)

grep -e"Peu[gG]eot" carlist.txt && vi /tmp/peugeot.txt

Run your command (in the background) to produce a temporary file, and edit the file, using ":e!" to refresh your file as it is produced (this is useful for logfiles, and other files being produced by another process, e.g. cron?),

grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt &
vi /tmp/peugeot.txt

Run vi(m), and run a child process to create the temporary file, and then read it,

vi
:!grep -e "Peu[gG]eot" carlist.txt > /tmp/peugeot.txt
:r /tmp/peugeot.txt

Or, just switch to the file,

:e /tmp/peugeot.txt

Run vi(m), and use the double-bang "!!" to have vi run the child command, taking the results and inserting them into the current location (overwrites the current line, so make sure you have a blank line),

vi
i
here
empty
there
<esc>
kk
!!grep -e "Peu[gG]eot" carlist.txt

And now you can write the file (if you want to) to any filename,

:w /tmp/someotherfilename.txt

And Petr Uzel's answer is also good,

grep -e "Peu[gG]eot" carlist.txt | vi -

Which reads from stdin