The UNIX and Linux Forums
>
Top Forums
>
UNIX for Dummies Questions & Answers
"vi"-ing a constantly updated file
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
"vi"-ing a constantly updated file
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
5
(
permalink
)
04-25-2007
Shell_Life
Registered User
Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Percy,
Here is one possible solution:
1) Rename the "work_file" to a "tmp_file" and immediately create a
new "work_file" so that new records can continue to be added to it.
Code:
mv work_file tmp_file touch work_file
2) "
vi
" the "tmp_file" and make all changes you want.
2.a) After you are finished with your changes on the "tmp_file",
do not quit yet.
2.b) Go to the end of the "tmp_file" and in the command line type:
Code:
:r work_file
This will read the "work_file" entirely and place it after the last line
of "tmp_file".
2.c) Write and quit the "tmp_file".
As you say the file is very large, if you try to save the work area
as "work_file", it may take a long time and use a lot of memory
and disk space.
3) Immediately rename "tmp_file" back to "work_file".
Code:
mv tmp_file work_file
See if this could work for you.
Shell_Life
View Public Profile
Find all posts by Shell_Life
Find Shell_Life's past nominations received
Find Shell_Life's present nominations given