Thursday, March 26, 2020

Re: "Auto Yes" to Warnings On Save (Scriptability)

The problem with using tail, sed, or similar is that they use intermediate files.  For the use case I'm describing, I need to be modifying the SAME file (same inode), because I'm trying to change a "live" file that the other process is writing to.  Living dangerously, I know.

On Thu, Mar 26, 2020 at 11:30 AM Gary Fritz <garyfritzz@gmail.com> wrote:
Yes, I think tail is a much simpler option.  Just be aware you can't do this:

tail -n 25 myfile > myfile

... because the "> myfile" opens and truncates the file (throwing away the contents) before the tail command runs.

Something like this would work:

tail -n 25 myfile > /tmp/tail$$
mv /tmp/tail$$ myfile

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/1c8d9b61-45b1-4977-a285-59a8a3cc9045%40googlegroups.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CA%2BpbHuEMDcKzHwQ6xf3_j05WnLVXyMFZ4NpMxCqNwKe9Wt9xPg%40mail.gmail.com.

No comments:

Post a Comment