Re: How to remove a single line from a flat file
- From: "Larry W. Virden" <lvirden@xxxxxxxxx>
- Date: 16 May 2007 04:53:56 -0700
In fact, I'd do such things not in Tcl but with utilities like gawk
mv datafile t
gawk '$1!="123096"' t > datafile
Which still has the problem of leaving the system without the file for
a period of time.
Well.. the only dangerous part is:
mv datafile t
Perhaps my comment wasn't clear - my concern wasn't so much the safety
of the rename, but the fact that datafile's contents are temporarily
unavailable using this technique. Think password file - with this
approach, until the gawk finishes, there would be no password file on
the system... not a good state to have your machine. Now, the shell
will immediately create an _empty_ datafile with the next line. That
still isn't the way you'd want your password file. There are other
types of files that are similarly problems.
My point is that for some files, this is not an issue. If the file is
purely used by one human reader, and that human reader is the one
working on the file, then the temporary missing file is no big deal.
If, on the other hand, one is working in a production environment
(which is my typical mode of thinking and working), and the presence
of the file, with contents, is critical to keeping the data center
running, then you don't want a solution that removes that file, even
for a bit. Instead, you have to think of alternatives - like the
database approach.
.
- Follow-Ups:
- Re: How to remove a single line from a flat file
- From: slebetman@xxxxxxxxx
- Re: How to remove a single line from a flat file
- From: Atte Kojo
- Re: How to remove a single line from a flat file
- From: Atte Kojo
- Re: How to remove a single line from a flat file
- References:
- How to remove a single line from a flat file
- From: Swaroop
- Re: How to remove a single line from a flat file
- From: Larry W. Virden
- Re: How to remove a single line from a flat file
- From: suchenwi
- Re: How to remove a single line from a flat file
- From: Larry W. Virden
- Re: How to remove a single line from a flat file
- From: slebetman@xxxxxxxxx
- How to remove a single line from a flat file
- Prev by Date: Re: Tcl/Tk on Rails
- Next by Date: Re: How to remove a single line from a flat file
- Previous by thread: Re: How to remove a single line from a flat file
- Next by thread: Re: How to remove a single line from a flat file
- Index(es):