sh script & files

Fbsd8 fbsd8 at
Wed Feb 20 13:00:49 UTC 2013

Polytropon wrote:
> On Wed, 20 Feb 2013 07:40:08 -0500, Fbsd8 wrote:
>> # write to file
>>  > "${file}"
>> I'm thinking the file is never closed so on power failure I loose the 
>> contents of the file.
>> How would I code a command to close the file?
> The file is closed when the write operation has been
> finished. You can use the "sync" command to flush
> pending writes to the file (as writing is handled
> asynchronously by the system). When the program
> that writes to the file exits, it will close the
> file it's writing to. This depends on the command
> you're using infront of >, as the command you've
> shown will simply generate a null file (file with
> no actual content).

The problem is there may be a great time lag between reading the file 
and the writing to the file, IE: days or months depending on how long 
between host reboots. I would just like to close the file right after 
the file gets read.

Is there a way to code that?

More information about the freebsd-questions mailing list